Я новичок в разработке iOS. мой массив содержит 50 значений я хочу, чтобы показать эти 50 значений в одном на один в 50 разделе, то я написать код, который вроде какНесколько разделов с одним массивом в tableview iOS
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.dataArray.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
затем я получил 50 раздел, но все секции содержат одинаковое значение массива я хочу показывают, что каждая секция содержит один на один data.Please дать мне какое-либо решение, если это было возможно
Мои TablwviewCell: Rowatindexpath метод
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *[email protected]"Cell";
CustumCell *cell=[tableView dequeueReusableCellWithIdentifier:cellidentifier];
if (cell == nil)
{
NSArray *nib=[[NSBundle mainBundle]loadNibNamed:@"CustumCell" owner:self options:nil];
cell=[nib objectAtIndex:0];
}
NSDictionary *dict = [self.imagesa objectAtIndex:indexPath.item];
NSString *img2=[dict valueForKey:@"post_image"];
[cell.photoimage sd_setImageWithURL:[NSURL URLWithString:[img2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] placeholderImage:[UIImage imageNamed:@"Hisoka.jpg"] options:SDWebImageProgressiveDownload completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"downloaded");
});
}];
NSString *name=[dict valueForKey:@"post_title"];
cell.namelabel.text=name;
NSString *des=[dict valueForKey:@"post_content"];
cell.deslabel.text=des;
NSDateFormatter * dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
NSString *date=[dict valueForKey:@"post_date"];
NSDate * dateNotFormatted = [dateFormatter dateFromString:date];
[dateFormatter setDateFormat:@"d-MMM-YYYY"];
NSString * dateFormatted = [dateFormatter stringFromDate:dateNotFormatted];
NSLog(@"Date %@",dateFormatted);
cell.datelabel.text=dateFormatted;
return cell;
}
Не могли бы вы разместить свой метод tableView: cellForRowAtIndexPath: '? – JoeFryer
Да, я публикую свой рабочий стол: метод cellForRowAtIndexPath. –
Одна из проблем заключается в том, что когда я запускаю это приложение и ничего не делаю, но через 2 - 3 минуты ошибка в строке NSDictionary * dict = [self.imagesa objectAtIndex: indexPath.item]; любое решение для этого ???? –