0
我想使用类似于键盘上的inputAccessoryView
的工具栏来解除UIPickerView。UIPicker子视图无法识别输入
我对我的文本字段和我的选择器都使用相同的UIToolbar,文本字段将会正常关闭,但选取器甚至不会识别我在按钮上的触摸。
这是我用来创建工具栏的代码:
UIToolbar *tipToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
tipToolbar.barStyle = UIBarStyleDefault;
UIBarButtonItem *donebtn = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(resignResponder:)];
tipToolbar.items = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
donebtn, nil
];
[tipToolbar sizeToFit];
_outlet_txt_ipaddr.inputAccessoryView = tipToolbar;
[_outlet_picker addSubview:tipToolbar];
这是将解雇键盘或选择器的操作:
- (IBAction)resignResponder:(id)sender{
[_outlet_txt_ipaddr resignFirstResponder];
[_outlet_picker resignFirstResponder];
}
工具栏会出现在拾取查看,但我点击完成按钮甚至没有显示动画,更不用说调用resignResonder
动作。
谢谢,这解决了我的问题! –