2012-03-12 2 views
0

私は、ストーリーボードを使用してXcode 4.2.1でTabBarアプリケーションを構築しています。問題は、UITableViewがIBで行った変更を反映していないことです。たとえば、IBを使用して背景色、Scrollerの可視性、セパレータの色を変更すると、UITableViewには目に見える効果はありません。IBから継承されたUITableViewのパラメータ

ただし、これらのパラメータをプログラムで設定すると、大きな効果が得られます。私は何が欠けていますか?以下のコード:

- (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を拡張するためにそれを変更し、すべてが適切な位置に落ちました。手動で設定していたものの多くは、UITableViewControllerクラスによって自動的に処理されるため、viewDidLoad()メソッドは大幅に簡略化されました。 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; 
} 
関連する問題