微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

iOS – UIToolBar作为UITextView的inputAccessoryView

我为UITextView添加一个带UIBarButtonItem的UIToolBar作为inputAccessoryView.它工作正常,但UIBarButtonItem可以在它的框架外触摸,也许在右边外面50像素.这没什么大不了的,但它让我烦恼.谁知道为什么?

这是我的代码(ARC):

UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,self.view.bounds.size.height,320,44)];
toolBar.barStyle = UIBarStyleBlack;
toolBar.translucent = YES;

UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneWriting:)];
[toolBar setItems:[NSArray arrayWithObjects:doneButton,nil]];

self.messageTextView.inputAccessoryView = toolBar;

解决方法

如果工具栏中没有其他附近的按钮,工具栏似乎会将按钮的活动区域扩展到其边界之外. Apple工程师必须认为最好是猜测用户打算按哪个而不是根本不做出反应.

原文地址:https://www.jb51.cc/iOS/331805.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐