表视图不显示数据,iphone
我现在正在使用UITableView以及我拥有的是什么
MyClass.h
@interface MyClass:UIViewController {
}
@属性(强,强)UILabel *名称;
@属性(强,强)UILabel *添加;
和
MyClass.m
- (NSInteger)tableView:(UITableView *)atableView numberOfRowsInSection:(NSInteger)section {
return 3 ;
}
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"cell";
tableCell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
...................................................
return tableCell;
}
当我在numberOfRowsInSection中放置断点时,它似乎根本没有被执行。 现在让我感到困惑。 如果您以前遇到过,请提供建议。
谢谢
最常见的原因是没有将视图控制器设置为表视图委托和数据源。 如果它是在故事板中构建的,则可以通过选择表格上的连接检查器并将这些属性拖到视图控制器来完成此操作。
否则,将其设置为如下所示的代码:
self.tableView.delegate = self;
self.tableView.datasource = self;
链接地址: http://www.djcxy.com/p/87725.html