2016-09-13 5 views
1

私はウォッチキットのテストアプリケーションで、ただのラベルをTableRowControllerとして持つ簡単なテーブルを持っています。ラベルのテキストを設定しようとすると、table.numberOfRowsが0を返すので、テーブルビューの行をループできません。WatchKitテーブルnumberOfRowsは0を返します

行の数は任意のxに設定されます。これにより、self.tableへのIB参照が機能していることが確認されます。

何が問題なのですか?ここで

は私のコードです:

- (void)awakeWithContext:(id)context { 
    [super awakeWithContext:context]; 

    // Configure interface objects here. 

    [self configureTableWithData]; 
} 

- (void)willActivate { 
    // This method is called when watch view controller is about to be visible to user 

    [super willActivate]; 
} 

- (void)didDeactivate { 
    // This method is called when watch view controller is no longer visible 
    [super didDeactivate]; 
} 

- (void)configureTableWithData { 
    [self.table setNumberOfRows:1 withRowType:@"RowController"]; 
    NSLog(@"%i",self.table.numberOfRows); 
    for (NSInteger i = 0; i < self.table.numberOfRows; i++) { 
     TableRowController* theRow = [self.table rowControllerAtIndex:i]; 
     [theRow.timeLabel setText:@"Hello!"]; 
    } 
} 

答えて

1

問題を追跡するために、実際には非常にシンプルですが、非常に難しかったです。私のTableRowControllerクラスは私のWatchKit Extensionのターゲットメンバーではなく、私のメインアプリだけでした。

関連する問題