【发布时间】:2012-02-07 21:21:40
【问题描述】:
我需要别人的帮助来声明以下数组:-
self.tablePicture = [NSArray arrayWithObjects:@"pic1.png", @"pic2.png", @"Country.png", nil];
为:-
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
// Configure the cell.
cell.textLabel.text = @"cell text";
cell.imageView.image = [UIImage imageNamed:[tablePicture objectAtIndex:indexPath.row]];
return cell;
}
如何在 .h 和 .m 文件中应用它?我对此很陌生。
提前致谢:)
PS。当我申请以下内容时,我会重复“pic1.png”并且没有数组。
{
self = [super init];
if (self) {
// Custom initialization
self.tableData = [NSArray arrayWithObjects:@"Region", @"Subregion", @"Country", @"County", @"City", @"District", nil];
self.tablePicture = [NSArray arrayWithObjects:@"pic1.png", @"pic2.png", @"Country.png", nil];
CGRect frame = self.view.bounds;
frame.size.height -= 100;
self.tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStyleGrouped];
[self.tableView setBackgroundColor:[UIColor clearColor]];
[self.tableView setDataSource:self];
[self.tableView setDelegate:self];
[self.tableView setScrollEnabled:NO];
[self.view addSubview:self.tableView];
}
return self;
}
【问题讨论】:
-
数组看起来不错,请检查下面的@beryllium 答案以获取下面的 .h 和 .m 内容。但是你的意思是没有细胞被输出吗?如果是这样,您是否实现了 UITableView 数据源并具有以下方法: – numberOfSectionsInTableView: – tableView:numberOfRowsInSection: ?
标签: objective-c ios uitableview