UITextView keyboard
2015-08-29 22:27
218 查看
from:http://inessential.com/2014/01/07/uitextview_scroll-to-typing_bug
UITextViewScroll-to-TypingBug
AsI’vesaidmanytimes,I’mahugefanofTextKit.It’sabigdealfor
ButwithTextKitcameanewUITextView.TheoldonewasbasedonWebView,andthisoneisn’t.Thatmakesita1.0versionofUITextView,sinceit’sanewthing.Andithassome
(Notsurprisinglyfora1.0.)
I’vebeentryingtofigureoutwork-aroundsforthese.I’mmakingprogress.
Settheframe,notthecontentInset
PeopleWhoKnow(tm)(GregPierce,forone)haveadvisedmenottosetthecontentInsetoftheUITextViewwhenthekeyboardappearsanddisappears.Insteadchangetheframe.Inmytestingthismakesabigdifference.Itmeansyoudon’tgettheblurred-outUITextViewunderneaththekeyboard,whichistoobad,butthattrade-offiseasytolivewith.
Scrollingtoshowtyping
Ihavethisalmostworking.LikeabottleofwineIjustcan’tmanagetoun-cork.FromGregPierce(again),authorof
-(void)textViewDidChangeSelection:(UITextView*)textView{
[textViewlayoutIfNeeded];
CGRectcaretRect=[textViewcaretRectForPosition:textView.selectedTextRange.end];
NSLog(@"y%f",caretRect.origin.y);
caretRect.size.height+=textView.textContainerInset.bottom;
[textViewscrollRectToVisible:caretRectanimated:NO];
}
Youcan
Theoneplaceitfails:
Tapattheendofthetext.
TapReturn.
Thecaretishidden.Typeanyotherkeyanditun-hides.ButIreally,reallywantthecarettobenothiddenrightthen.
Ifyoulookintheconsoleyou’llnotethat
caretRect.origin.yisjustplainincorrectwhenyoutapReturn.
YoucantapReturnagainandthenbackspaceandseethesamething—onlycaretRect.origin.ywillbewronginadifferentdirection.
Soclose.Icanalmosttastethewine.Ifyouhaveanyideas,
trymore.
07Jan2014
相关文章推荐
- CRB and Queries(动态区间求第k小数模板题:线段树套平衡树)
- 安卓 requestFeature() must be called before adding content 错误
- HDU 2604 Queuing (递推+矩阵快速幂)
- The current branch is not configured for pull No value for key branch.master.merge found in configur
- UITextField 学习知识点
- UI中提供的七种手势
- UIButton 学习知识点
- UI-PassValue界面之间传值
- UI-UINavigationController导航栏
- ZooKeeper实现分布式队列Queue
- iOS 并发编程之 Operation Queues
- UILabel 学习知识点
- UIView 学习知识点
- UILabel
- UI_11 自定义UITableViewCell、Cell的高度自适应
- UIButton的简单使用
- iOS开发之有趣的UI —— 数据转模型及MVC设计模式
- Android UI 绘制过程浅析(五)自定义View
- 滑块控件UISlider
- 分段控件UISegmentedControl