每当我打开UITextView时,我都会在我的键盘上显示一个工具栏。这是我目前的代码。
UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
numberToolbar.barStyle = UIBarStyleBlackTranslucent;
numberToolbar.items = [NSArray arrayWithObjects:[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(done:)],nil];
[numberToolbar sizeToFit];
self.yourTextView.inputAccessoryView = numberToolbar;
然而,当我按下按钮时,应用程序崩溃了。如何将按钮设置为按下的位置,将光标切换到另一个UITextView?
答案 0 :(得分:0)
使用此代码,如果您不需要
,请不要传递参数UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
numberToolbar.barStyle = UIBarStyleBlackTranslucent;
numberToolbar.items = [NSArray arrayWithObjects:[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(done)],nil];
[numberToolbar sizeToFit];
self.yourTextView.inputAccessoryView = numberToolbar;
-(void)done
{
NSLog(@"hello");
}