如何使用UINavigationBar中的UITextView导航到下一个UIViewController
我试图使用一个UITextView作为一个button,点击UITextView后,它应该popup到另一个UIViewController(不是根,下一个)。
使用UIButton可以正常工作(通过拖到下一个UIViewController并select“Push”作为seguetypes,而不需要进行任何编码)。 但是,用UITextView做同样的事情是行不通的!
所以,我的问题是如何使用UITextField导航到下一个视图控制器?
尝试添加一个UITapGestureRecognizer
到文本视图并使用该callback触发一个segue。
我不认为你没有代码就可以做到这一点。
添加点击手势到UITextView
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mySelector)]; tapRecognizer.numberOfTapsRequired = 1; [_textView addGestureRecognizer:tapRecognizer];
在UITapGestureRecognizer操作方法中推送或呈现UIVieWController。
-(void)mySelector { // Navigate to next view controller }
设置userInteractionEnabled属性?
textView.userInteractionEnabled = YES;
你应该可以使用textView像一个button…
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myTapped:)]; tapRecognizer.numberOfTapsRequired = 1; [txtView addGestureRecognizer:tapRecognizer]; -(void)myTapped::(UIGestureRecognizer *)gesture { // Do what you want here }
试试这个代码
- 核心数据获取与瞬态关系谓词!=无
- 在后台线程读CGImageRef崩溃的应用程序
- dismissModalViewControllerAnimated在iOS6上崩溃
- 如何在ios项目中实施Google Drive和Google Plus sdk
- 创buildUICollectionViewCell时,子视图框架不正确
- 带有崩溃符号的Xcode错误上传:symbolFileUploadLocation:调用者没有权限
- 刷新UICollectionView
- 在ios7中,UITableViewCellAccessoryDetailDisclosureButton分为两个不同的附件button
- UIWebView不能使用loadRequest加载站点的移动版本