【发布时间】:2015-07-17 08:21:26
【问题描述】:
我有一个 UITextField,当 UITextField 是 UIScrollView 的子视图时,文本字段操作不起作用。
其他方面,它工作正常, 这是我的代码.. 请帮忙?
我正在使用此代码,因为我需要在单击 alertview 按钮后立即触发 UIDatePicker。
- (void)viewDidLoad {
[super viewDidLoad];
UIScrollView *scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
[self.view addSubview:scroll];
date = [[UITextField alloc]initWithFrame:CGRectMake(80, 150, 150, 50)];
date.placeholder = @"Date";
date.delegate = self;
[date addTarget:self action:@selector(dateClicked:) forControlEvents:UIControlEventTouchDown];
[scroll addSubview:date];
}
- (void)dateClicked:(id)sender
{
NSLog(@"CLICKED");
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Choose Date Format" message:nil delegate:self cancelButtonTitle:@"dd/MM/YYYY" otherButtonTitles:@"MM/dd/YYYY", nil];
[alertView show];
}
【问题讨论】:
-
使用 UIControlEventEditingDidBegin 代替 UIControlEventTouchUpInside
-
它的工作,但我想在更新文本字段文本的 alertView Button CLick 上打开一个 uipicker,如果我使用 UIControlEventEditingDidBegin 然后在更新文本后,alertview 将再次打开@Saurabh
标签: ios objective-c iphone uiscrollview uialertview