我在[UITextView(toolbar) addKeyboardToolbar]
时遇到问题,在tableView:CellForRowAtIndexPath
我添加了此方法,如[cell.textView addKeyboardToolbar];
我在Crashly中遇到了像
这样的问题崩溃:com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS at at 0x00000008
这是我的代码如下。 有谁可以帮我这个 提前谢谢。
- (void)addKeyboardToolbar
{
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.bounds.size.width, 44.0f)];
[toolBar setBarStyle:UIBarStyleBlack];
[toolBar setTranslucent:YES];
// toolBar.items=[NSArray arrayWithObjects: [[UIBarButtonItem alloc]initWithTitle:@"Spacer" style:UIBarButtonItemStyleBordered target:self action:nil],
// [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
// [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(hideKeyboard)],
// nil];
// [toolBar sizeToFit];
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(hideKeyboard)];
[toolBar setItems:[NSArray arrayWithObjects:spacer, done, nil] animated:YES];
[toolBar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
if ([self isKindOfClass:UITextField.class]) {
[self setInputAccessoryView:toolBar];
} else if ([self isKindOfClass:UITextView.class]) {
[self setInputAccessoryView:toolBar];
}
//return toolBar;
}