带有autolayout的UIScrollView返回包括工具栏在内的框架大小

时间:2016-02-26 15:22:26

标签: uiscrollview autolayout ios9

我的def stripVowelsRecursive(str: String): String = if (str.isEmpty) "" else (if (isVowel(str.head)) str.head else "") + stripVowelsRecursive(str.tail) def stripVowelsRecursiveOpt(str: String): String = { def go(acc: List[Char], chars: Seq[Char]): String = chars match { case ch +: rest if isVowel(ch) => go(acc, rest) case ch +: rest => go(ch :: acc, rest) case Nil => acc.reverse.mkString } go(Nil, str) } def stripVowelsLoop(str: String): String = for (ch <- str if isVowel(ch)) yield ch def stripVowelsSimples(str: String): String = str.filter(isVowel) 中有UIScrollView,使用AutoLayout定位:

UIViewController

当我现在尝试获得 self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[scrollView(width)]-0-|", options: .DirectionLeadingToTrailing, metrics: ["width":CGRectGetWidth(self.view.bounds)], views: ["scrollView":self.scrollView])) self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[continueButton]-0-|", options: .DirectionLeadingToTrailing, metrics: nil, views: ["continueButton":self.continueButton])) self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:[scrollView]-0-[continueButton(50)]-0-|", options: .DirectionLeadingToTrailing, metrics: nil, views: ["scrollView":scrollView, "continueButton":self.continueButton])) self.view.addConstraint(NSLayoutConstraint(item: self.scrollView, attribute: .Top, relatedBy: .Equal, toItem: self.topLayoutGuide, attribute: .Bottom, multiplier: 1, constant: 0)) 的高度之后:

UIScrollView

我得到的尺寸太高 - 它包括导航和状态栏。如果我设置

,它没有任何区别
    self.view.setNeedsLayout()
    self.view.layoutIfNeeded()

    print(CGRectGetHeight(self.scrollView.frame))

与否,我得到的高度总是相同和错误。我在这里错过了什么?我怎样才能获得真实的self.automaticallyAdjustsScrollViewInsets = false 框架?

0 个答案:

没有答案