1
アレイから3つの異なるイメージをUITableの対応するセルにロードしようとしています。これまでのところ、私はtが実行されたときに細かいクラッシュを生成する次のコードを持っています。私はfanyoneが私を助けることができてとても感謝しています。アレイからUITabeViewに別のイメージをロードする
- (void)viewDidLoad {
NSArray *array = [[NSArray alloc] initWithObjects:@"Icon Nightclub", @"Smyhts Bar",
@"Synotts",nil];
self.listData = array;
NSArray *picArray = [[NSArray alloc] initWithObjects:@"ArrowLeftDefault.png", @"ArrowRightDefault.png",
@"events.png",nil];
self.picData = picArray;
[array release];
[picArray release];
[super viewDidLoad];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [listData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease];
}
NSUInteger row = [indexPath row];
cell.textColor = [UIColor grayColor];
cell.textLabel.text = [listData objectAtIndex:row];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.imageView.image = [picData objectAtIndex:indexPath.row];
return cell;
}
あなたは私よりも速いです。 :)はい、これが答えです。 picData配列にはUIImagesではなく文字列の配列が含まれているため、コードがクラッシュしています – Walter
ああ素晴らしいです。乾杯。私はそれを見つけたはずです。私はこれほど長くはない。あなたは私のベーコンを救った。 – krosullivan
Walterさん、ありがとうございました。 – nacho4d