带有消失按钮的InputAccessoryView

时间:2013-05-24 12:18:40

标签: ios accessoryview

我将这个InputAccessoryView显示为textview,它工作正常。但是,如果我在附件视图上单击shareButton,然后单击取消继续写入,则附件视图将变空。它仍然显示为工具栏,但所有按钮都消失了,我在这里做错了什么?

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
UIToolbar *toolbar = [[UIToolbar alloc] init];
[toolbar setBarStyle:UIBarStyleBlackOpaque];
[toolbar sizeToFit];

UIBarButtonItem *shareButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(shareIt:)];

UIBarButtonItem *flexButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];

UIBarButtonItem *doneButton =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(resignKeyboard)];

NSArray *itemsArray = [NSArray arrayWithObjects:shareButton, flexButton, doneButton, nil];


[toolbar setItems:itemsArray];

[_textView setInputAccessoryView:toolbar];

return YES;
}

这是方法shareIt:

- (void)shareIt:(id)sender {
NSArray *activityItems;

activityItems = @[_textView.text];


UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];
NSLog(@"buttonCalle");
}

0 个答案:

没有答案