我有一个UIScrollView里面有几个动态视图,每个视图都有一个文本字段.当我开始在其中一个框中键入内容时,我希望滚动视图滚动,以便该字段位于屏幕顶部(在键盘上方可见).它很棒; 这是代码:
(void)didStartTyping:(id)sender {
[scrollView setContentOffset:CGPointMake(0, subView.frame.origin.y) animated:YES];
scrollView.scrollEnabled = NO;
}
(void)didFinishTyping:(id)sender {
scrollView.scrollEnabled = YES;
}
Run Code Online (Sandbox Code Playgroud)
但是,每当滚动视图滚动到最顶部并且我开始键入最低的可见文本字段时,它不会向下滚动得足够远(短约40 px).令人费解的是,如果我从滚动视图的顶部向下滚动一个像素,它就可以工作,但是当我向上滚动到顶部时,它的表现非常不同.
如何使用Swift从字符串中删除,而不是解码百分比转义字符.例如:
"hello%20there"
应该成为
"hellothere"
编辑:
我想替换字符串中的多个转义百分比字符.所以:
"hello%20there%0Dperson"
应该成为
"hellothereperson"