0
我有一個UITableView,我通過initWithFrame動態添加。Code driven UITableView not delegating
- (void)twitterUpdate {
twitterTable = [[UITableView alloc] initWithFrame:CGRectMake(40, 100, 420, 750)];
twitterTable.delegate = self;
twitterTable.backgroundColor = [UIColor clearColor];
twitterTable.separatorColor = [UIColor darkGrayColor];
twitterTable.dataSource = self;
[twitterView addSubview:twitterTable];
}
不幸的是,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
不會被調用,儘管我曾
<UITableViewDataSource, UITableViewDelegate>
在我的頭文件中定義。
任何想法爲什麼這不叫? twitterUpdate正在通過調用
[self performSelectorOnMainThread:@selector(twitterUpdate) withObject:self waitUntilDone:YES];
並正在將該表繪製到頁面。我也有
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
返回一個有效的NSInteger。
你不能動態創建這樣的表嗎?
你說numberOfRowsInSection返回一個有效NSInteger的...是大於0? – MarkPowell 2011-03-21 18:21:07
是的。我甚至嘗試手動設置它。 – 2011-03-21 18:23:47
你真的100%肯定numberOfSectionsInTableView:返回值> 0和tableView:numberOfRowsInSection:返回值> 0爲特定部分?因爲你可以用這種方式添加UITableView而沒有問題。 – robertvojta 2011-03-21 18:26:08