iOS开发~UITextView光标不在起始位置问题
2015-12-04 15:46
531 查看
问题:当用UITextView展示超出屏幕的文本内容时,并且禁止了其编辑功能,发现打开页面后,光标不在开头位置,而是在屏幕中间
解决办法:
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.contentTextView.editable = NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.contentTextView.attributedText = attributedString;
self.contentTextView.editable = YES;
[self.contentTextView becomeFirstResponder];
self.contentTextView.selectedRange = NSMakeRange(0,0);
self.contentTextView.tintColor = [UIColor clearColor];
}
解决办法:
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.contentTextView.editable = NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.contentTextView.attributedText = attributedString;
self.contentTextView.editable = YES;
[self.contentTextView becomeFirstResponder];
self.contentTextView.selectedRange = NSMakeRange(0,0);
self.contentTextView.tintColor = [UIColor clearColor];
}
相关文章推荐
- 在iOS 8中使用UIAlertController
- 融云Android 2.0 IMkit UI样式更改
- ffmpeg---CompilationGuide
- UIWindow & UIWindowLevel笔记
- git clone: SSL certificate problem: unable to get local issuer certificate
- vm虚拟机出现目标主机不支持CPUID的情况
- pyquery安装
- [LeetCode 307] Range Sum Query - Mutable
- U3D打图集流程
- iOS重写系统中的UINavigationController返回按钮的事件
- MySQL.. ERROR! The server quit without updating PID file问题解决
- [cc150]Chapter 3 | Stacks and Queues
- UITableView 左右滑动时,出现删除按钮的动画
- easyui动态添加组件没有样式
- poj 1679 The Unique MST
- 滚动指定UITableViewCell到顶部
- Build Settings中的变量@rpath,@loader_path,@executable_path
- UI视图控件、视图嵌套、SubView、Tag 的使用
- Android UICC 实现框架和数据读写
- LeetCode(304)Range Sum Query 2D - Immutable