我开始了一个选项卡式应用程序项目,在我的第一个视图中,我想获得一个填充列表,所以我声明了一个 NSArray,如下所示:
@interface agrospineFirstViewController : UIViewController <UITableViewDelegate ,UITableViewDataSource>
{
NSArray *JournalList;
}
@property (nonatomic,retain) NSArray *JournalList;
@end
我在 .m 上添加了以下内容:
[超级视图DidLoad];
//initialisation de la liste
JournalList = [NSArray arrayWithObjects:@"journal1",@"journal2",nil];
//initialisation du table View
UITableView* tableView=[[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]style:UITableViewStylePlain];
//population de la vue
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [JournalList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];
// Configuration de la cellule
NSString *cellValue = [JournalList objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
我也将表格列表放入视图中......但仍然在 numberOfRowsInSection 上显示错误,要求将“:”替换为“;” 有什么帮助建议可以改进吗?
感谢您的时间