LoginSignup
22
20

More than 5 years have passed since last update.

StoryboardでUIScrollViewを配置する場合

Last updated at Posted at 2014-01-14

Storyboard上ではcontentSizeが設定できないのでそのままではスクロールができない。
しかし以下の様に、viewWillAppear: 内でcontentSizeを入れてもまだスクロールできない。

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.scrollView.contentSize = self.imageView.bounds.size;
}

http://labs.septeni.co.jp/?p=910
こちらによると、どうやらAutoLayoutがレイアウトを決定するのは viewDidLayoutSubviews 以降らしい。

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    self.scrollView.contentSize = self.imageView.bounds.size;
}

これで無事スクロールされるようになった。

22
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
20