【问题标题】:UIScrollView does white space and doesn't scrollUIScrollView 做空白并且不滚动
【发布时间】:2014-05-20 04:54:11
【问题描述】:

我有一个场景,我尝试实现但无济于事 - 将带有文本框的滚动视图放在页面控制器中。

这是我所做的 - UIPageViewController->ViewController with data ->UIView ->UIScrollView -> UITextView。

它有什么作用?好吧,除了滚动一点(不显示所有文本)并在底部显示一个奇怪的白条之外,什么都没有。

有用的sn-ps代码-基本上我链接了我的高度约束,然后在代码中:

- (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;
}

但是没有。

提前致谢

【问题讨论】:

  • 你设置 contentSize 了吗?
  • AFAIK 在使用 iOS 7 和自动调整大小时不再有效?
  • 尝试在滚动视图和文本视图之间放置一个视图。这会给滚动视图一些界限。
  • 你的意思是滚动视图->视图->文本视图层次还是滚动视图->视图、文本视图层次?

标签: ios iphone objective-c uiscrollview


【解决方案1】:

这解决了我的问题——显然我应该调用一个选择器...

-(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);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-12
    • 2012-07-30
    • 1970-01-01
    • 2018-11-19
    • 2013-06-12
    相关资源
    最近更新 更多