0

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

- (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");
}
4

0 回答 0