我有一个通过 initWithFrame 动态添加的 UITableView。
- (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。
你不能像这样动态创建表吗?
最佳答案
确保你打电话:
[twitterTable reloadData];
关于iphone - 代码驱动的 UITableView 不委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5381774/