0

ビューの 1 つを構成しようとしています。寸法は適切に設定できますが、自動サイズ変更マスクを追加すると、すぐにサイズが変更されます。

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - self.tabBarController.tabBar.frame.size.height - self.navigationController.navigationBar.frame.size.height - 10)]; // -10 so I know it's not being hidden under the tabbar
    scrollView.backgroundColor = [UIColor greenColor]; // easy recognition
    scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [self.view addSubview: scrollView];
    self.scroll = scrollView;
    UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(hmm)];
    [self.navigationController.navigationBar addGestureRecognizer: tap];

}

- (void) hmm {
    NSLog(@"Frame: %@", [NSValue valueWithCGRect: self.scroll.frame]);
}

マスクなしで 357、マスクありで 264 です。スクロールビューとタブバーの間にマスクのある大きな白いセクションがあります。なぜこのようになっているのですか?どうすれば修正できますか?

4

1 に答える 1

0

ナビゲーションとタブバーを考慮する必要はありません。

これを試して。スクロールビューを開始するときは、サイズを変更する前にビューのサイズにします。ビューが読み込まれると、ビューのサイズが自動的に変更されます。

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height- 10)]; // -10 so I know it's not being hidden under the tabbar
    scrollView.backgroundColor = [UIColor greenColor]; // easy recognition
    scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [self.view addSubview: scrollView];
    self.scroll = scrollView;
    UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(hmm)];
    [self.navigationController.navigationBar addGestureRecognizer: tap];

}
于 2013-06-12T05:23:38.510 に答える