我有一个带外部委托控制器的tableview.尽管内容表视图数组已经很好地填充,numberOfSectionsInTableView:并且
-tableView: numberOfRowsInSection:被调用,
但是-tableView: cellForRowAtIndexPath:没有被调用.
发布的表视图以这种方式设置:
CompeticionViewController.h
....
@property (retain, nonatomic) IBOutlet UITableView *calendarioTable;
@property (strong, nonatomic) calendarioViewController *calendarioController;
....
calendarioTable = [[UITableView alloc] init];
calendarioController = [[calendarioViewController alloc] init];
[calendarioTable setDelegate:calendarioController];
[calendarioTable setDataSource:calendarioController];
calendarioController.calendarioArray = [[NSMutableArray alloc] init];
[calendarioController.calendarioArray addObjectsFromArray: self.calendarioarray];
[calendarioTable reloadData];
Run Code Online (Sandbox Code Playgroud)
编辑:
calendarioViewController.m
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [calendarioArray count];
}
Run Code Online (Sandbox Code Playgroud)
非常感谢
你已经用了IBOuletfortableview那么你为什么要把allocating它当作它的not need memory already allocated。
现在签入xib您的视图控制器tableview并将binded其delegate提供datasource给file owner。
- - - - - - - - - - - - - - - - - - - - -或者- - - - ----------------------------------------------------
add这条线在viewDidLoad method
yourtableview.delegate=self
yourtableview.datasource=self;
Run Code Online (Sandbox Code Playgroud)
现在使用IBOuletfor之后tableview,您将把它与文件所有者和 ViewController绑定interface implements在一起<UITableViewDelegate><UITableViewDataSource> protocols
现在check array你已经providing在tableview其中content了
编辑:添加 OR 代码并完成格式化
| 归档时间: |
|
| 查看次数: |
2414 次 |
| 最近记录: |