iOS custom table cannot scroll to the bottom

最近用XCode開了一個簡單的*.nib file,裡面只有一個Table View,其中Table View有透過IB設定Row Height為80,並額外客製一個*.nib file給Table View Cell用,除此之外都用預設條件!

呈現資料時遇到一個小問題,最後一列資料老是被遮住一半
本來是想到Status Bar有自身高度需要扣掉的問題,在viewDidLoad寫了偵測高度並扣除的程式

    BOOL isPortrait = self.interfaceOrientation == UIInterfaceOrientationPortrait;
    CGSize statusBarSize = [UIApplication sharedApplication].statusBarFrame.size;
    CGFloat statusBarHeight = (isPortrait ? statusBarSize.height : statusBarSize.width);
    NSLog(@"statusBarHeight:%f", statusBarHeight);
    NSLog(@"statusBarHeight:%f", self.myTable.frame.size.height - statusBarHeight);
    self.myTable.frame= CGRectMake(self.myTable.frame.origin.x, self.myTable.frame.origin.y, self.myTable.frame.size.width, self.myTable.frame.size.height - statusBarHeight);

效果不好~還是有少部分被遮住@@

後來才發現是使用AutoLayout的後遺症,原來在AutoLayout爽爽用的情況下,也要注意Constraints設定,設定正確就可以免寫一堆醜陋程式碼汙染專案XD

設定前

設定後

沒有留言: