我有一个场景,我试图实现但无济于事 - 放置一个带有文本框的 ScrollView ,所有这些都在页面 Controller 中。
这是我所做的 - UIPageViewController->ViewController with data -> UIView -> UIScrollView -> UITextView。
它能做什么?好吧,除了滚动一点(不显示所有文本)并在底部显示一个奇怪的白条之外,什么都没有。
有用的代码片段 - 基本上我链接了我的高度约束,然后在代码中:
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
//CGSize sizeThatShouldFitTheContent = [_textView sizeThatFits:_textView.frame.size];
self.theScrollView.frame = CGRectMake(self.theScrollView.frame.origin.x, self.theScrollView.frame.origin.y, 320, 2000);//[_theScrollView sizeThatFits:_theScrollView.frame.size];
_heightOfText.constant = 2000; //sizeThatShouldFitTheContent.height;
//_textView.frame = CGRectMake(_textView.frame.origin.x, _textView.frame.origin.y, sizeThatShouldFitTheContent.width, sizeThatShouldFitTheContent.height);
_textView.scrollEnabled = NO;
NSLog(NSStringFromCGRect(self.theScrollView.frame));
self.theScrollView.scrollEnabled = YES;
}
但是没有。
提前致谢
最佳答案
这解决了我的问题 - 显然我应该调用一个选择器......
-(void)viewDidLoad
{
// Change the size of page view controller
self.pageViewController.view.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height + 40);
[self performSelector:@selector(adjustScrollViewContentSize) withObject:nil afterDelay:0.1];
}
-(void)adjustScrollViewContentSize
{
_scrollView.contentSize = CGSizeMake(4000, 4000);
}
关于ios - UIScrollView 做空白并且不滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22921028/