[英]Toolbar and Textfield problem
我有一个iPad项目。 在项目中,我有一个工具栏,然后我就可以添加一个文本框。 这是我的简化代码。
- (void)viewDidLoad {
[super viewDidLoad];
UITextField *pageNumbersView = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
pageNumbersView.clearsOnBeginEditing = YES;
pageNumbersView.borderStyle = UITextBorderStyleRoundedRect;
pageNumbersView.textAlignment = UITextAlignmentCenter;
pageNumbersView.userInteractionEnabled = YES;
pageNumbersView.keyboardType = UIKeyboardTypeNumberPad;
pageNumbersView.returnKeyType = UIReturnKeyDone;
UIBarButtonItem *pagesIndicator = [[UIBarButtonItem alloc] initWithCustomView:pageNumbersView];
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 100, 768, 44)];
toolbar.items = [NSArray arrayWithObject:pagesIndicator];
[self.view addSubview:toolbar];
}
当我单击文本字段时,将出现键盘。 现在的问题是,在键盘上,我按下了键盘底部最右边的按钮(键盘隐藏按钮?),却什么也没发生。 如果我将文本字段添加到视图不工具栏是工作。 对这个问题有任何想法吗? 我该如何解决? 感谢您的回答。
尝试使用界面生成器添加文本字段,而不是对其进行硬编码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.