2012-03-12 47 views
0

我有一個使用故事板在Xcode 4.2.1中構建的TabBar應用程序。問題是UITableView沒有反映我在IB中做出的更改。例如:當我使用IB對背景顏色,滾動條可見性,分隔符顏色進行更改時,UITableView沒有可見的效果。UITableView PARAM不從IB繼承

但是,如果我以編程方式設置這些參數,它們工作得很好。我錯過了什麼?一些代碼如下:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    // get a pointer to our delegate. This is where the data will be stored 
    // which gets passed between the Views (e.g. Favorites) 
    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 

    myTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain]; 

    myTableView.dataSource = self; 
    myTableView.delegate = self; 
// myTableView.backgroundColor=[UIColor blackColor]; 

    // this will suppress the separator lines between empty rows. 
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)]; 
    myTableView.tableFooterView = view; 

    self.view = myTableView; 
} 

回答

0

修復:上面的類擴展了ViewController。我改變它來擴展UITableViewController,一切都落在了原地。 viewDidLoad()方法現在大大簡化了,因爲我手動配置的很多東西都是由UITableViewController類自動處理的。我可以按預期更改IB中的UITableView參數。

- (void)viewDidLoad 
{ 
    // during construction, call the super class's method FIRST. 
    [super viewDidLoad]; 

    // get a pointer to our delegate. This is where the data will be stored 
    // which gets passed between the Views (e.g. Favorites) 
    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 

    // this will suppress the separator lines between empty rows. 
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)]; 
    self.tableView.tableFooterView = view; 
}