【发布时间】:2018-04-22 14:59:12
【问题描述】:
在 iOS Objective-C 应用程序中,我试图在键盘顶部设置一个栏。我希望键盘通过位于此栏中的 UITextView “激活”。但是我无法显示该栏。
我的理解:
- (void)viewDidLoad
{
myUIView=[[UIView alloc]initWithFrame:xxx]; // 1. Create an UIView that will serve as inputAccessoryView
myTextView=[[UITextView alloc]init]; // 2. Create a UItextView
[myUIView addSubview:myTextView]; // 3. Add it to the UIView
[myTextfield setInputAccessoryView:myUIView]; // 4. Set the UIview as being the inputAccessoryView of the textView
// [self.view addSubview:myUIView]; // If I do this, the view is displayed but the app crashes when tapping in the textField
}
但是视图没有显示,textView 也没有。
我试图将 textView 作为主控制器视图的子视图,当 textview 显示时,myUIView 没有
我在这种方法中做错了什么?
【问题讨论】:
-
你可以试试IQKeyboard作为你的accessoryView吗?如果你想这样做。点击视图和视图应该在键盘上方。
标签: ios objective-c uiview inputaccessoryview