#UIAutoScrollView
在开发过程中,如一个页面有许多的输入控件,UITextField和UITextView。编码的时候就要考虑控件获得焦点后,键盘是否会把这个控件遮
挡,就得操作UIScrollView的滚动条位置。
我开发了UIAutoScrollView类,它能自动处理键盘遮挡问题,达到了一劳永逸的效果!
##使用注意
1.如果是xib的方式使用这个类,不需要调用这个addAutoScrollAbility方法,我在awakeFromNib方法里调用了。 在xib中使用时,先在
xib中拖入一个UIScrollView,然后再把它的class属性设置为 UIAutoScrollView
2.如我在Demo 中的CodeScrollTestViewController中用UIAutoScrollView。必须设置UIAutoScrollView的contentSize,在加完
UIAutoScrollView的所有子控件的后,最后再调用下addAutoScrollAbility方法,这个顺序不能变。
3.如我在Demo 中的CodeScrollTestViewController中用UIAutoScrollView。在viewDidLoad中设置了
self.view.frame=CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen
mainScreen].bounds.size.height-self.navigationController.navigationBar.frame.size.height-[UIApplication
sharedApplication].statusBarFrame.size.height); 这里必须设置下view的frame,原因是这时候view的高度已经超出了手机屏幕。
超出了navigationBar和statusBar的高度. 如果不这样设置后面的代码设置UIAutoScrollView的frame等于view的frame的时候,会造成
UIAutoScrollView超出手机屏幕,这样在UIAutoScrollView内部计算的时候会出bug.
-
Notifications
You must be signed in to change notification settings - Fork 0
lqCoder/UIAutoScrollView
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
An easy way to use UIScrollView roll(当有输入框的时候,控制它的contentOffset,防止键盘遮挡控件)。
Resources
Stars
Watchers
Forks
Releases
No releases published