Utworzono niestandardową komórkę FeatureCell, która ma 5 obrazów w wierszu, który zostanie wywołany w widoku głównym, ale gdy go wywołasz, otrzymam pusty wiersz. Więc proszę, gdzie może być mój problem?Wywołanie dwóch różnych komórek niestandardowych w jednym wydaniu UITableView
Mam google o niestandardowej komórce i użyłem sposobu, który muszę użyć w poniższym kodzie, ale nic się nie dzieje.
To mój FeatureCell.h
@interface FeatureCell : UITableViewCell{
IBOutlet UIImageView *img1;
IBOutlet UIImageView *img2;
}
@property (nonatomic, retain) UIImageView *img1;
@property (nonatomic, retain) UIImageView *img2;
@end
To mój FeatureCell.m
@implementation FeatureCell
@synthesize img,img1,img2,img3,img4;
@end
To jest mój widok-kontroler .m
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section == 0) {
return [objectCollection count];
}
else{
return 1;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier1 = @"FeatureCell";
FeatureCell *cell1 = (FeatureCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
if (cell1 == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:cellIdentifier1 owner:nil options:nil];
cell1 = (FeatureCell*)[nib objectAtIndex:0];
}
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:CellIdentifier];
}
if ([indexPath section] == 0) {
containerObject = [objectCollection objectAtIndex:indexPath.row];
[[cell textLabel] setText:containerObject.store];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
else{
cell1.img1.image = [UIImage imageNamed:@"shower.png"];
cell1.img2.image = [UIImage imageNamed:@"parking.png"];
}
return cell;
}
Czy połączyć placówki? – Wain
To nie jest właściwy sposób postępowania z 2 różnymi typami komórek. Zobacz moją odpowiedź tutaj: http://stackoverflow.com/questions/17711452/change-uicollectionviewcell-content-and-nib-layout-based-on-data/17711644#17711644. Dotyczy to widoków kolekcji, ale jest tak samo w przypadku widoków tabel. – rdelmar
@Wain co masz na myśli przez outlety? –