我在自定义的UITableViewCell中有一个UITextView。我使用UITextView主要是为了在cell上提供数据检测。我为不同的单元格设置了自己的自定义UIMenuitems。
|-------------------------------|
| |
| |------------------| |
| | | |
| | UITextView| |
| |__________________| |
| |
| UITableViewCell|
|_______________________________|我面临的问题是,当我点击UITextView中的区域时,我没有得到任何菜单控制器,预期的行为是,它应该调用为颗粒UITebleViewCell定义的相同的菜单控制器。
如果我用UILabel替换UITextView,我可以得到正确的菜单控制器,但是我失去了数据检测能力。
请指导我正确的方向,我遗漏了什么或我做错了什么?
发布于 2014-07-18 16:12:03
您可以使用UITapGestureRecognizer来检测文本视图上的点击。
的userInteractionEnabled为TRUE
myTextView.userInteractionEnabled = TRUE;
UITapGestureRecognizer *tapGestureRecognizer = [UITapGestureRecognizer alloc :self action:@selector(myTextViewTapped:)];myTextView addGestureRecognizer:tapGestureRecognizer;
(@“点击我的文本视图”);//立即显示菜单!NSLog
//在您的表视图中cellForRowAtIndexPath方法myTextView.tag = indexPath.row;//在您的选择器中UITextView *myTextView = (UITextView *)cellForRowAtIndexPath;int rowNumber = myTextView.tag;
https://stackoverflow.com/questions/24818937
复制相似问题