Awe*_*e-o 3 iphone objective-c uiview ios inputaccessoryview
这是易如反掌增加一个inputAccessoryView上UITextField,UITextView或UISearchBar.但是,就UIView我所知,没有明显而简单的方法可以为你的基本添加一个!
我有一个UIView遵循UIKeyInput协议的子类.它接收键盘输入,做的东西,是不相关的输入文字,所以我宁愿不强迫它继承前者规定的意见,因为它增加了膨胀和会暴露了一堆没有做任何属性,加上我我需要解决这些类本身发生的文本条目(更膨胀).
但是,我UIView确实需要在其显示的键盘上输入附件视图才能正常工作.
有什么简单的方法可以解决这个问题吗?我是否必须UIKeyboardWillShowNotification在UIView子类中注册为观察者并手动将子视图作为附件视图添加到其中?
您是否尝试过将inputAccessoryView方法添加到viewController中?我相信在显示键盘时会调用它,因此您实际上不必为每个textField或视图分配一个键盘.
- (UIView *)inputAccessoryView
{
if (!inputAccessoryView)
{
CGRect accessFrame = CGRectMake(0.0, 0.0, 768.0, 77.0);
inputAccessoryView = [[UIView alloc] initWithFrame:accessFrame];
inputAccessoryView.backgroundColor = [UIColor blueColor];
UIButton *compButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
compButton.frame = CGRectMake(313.0, 20.0, 158.0, 37.0);
[compButton setTitle: @"Word Completions" forState:UIControlStateNormal];
[compButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[compButton addTarget:self action:@selector(completeCurrentWord:) forControlEvents:UIControlEventTouchUpInside];
[inputAccessoryView addSubview:compButton];
}
return inputAccessoryView;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4137 次 |
| 最近记录: |