我正在使用Objective C和Parse。我有一个显示Parse照片的UITableView。前10个单元加载然后你可以为下10个单元加载更多,依此类推。我的问题与我收到照片的同一个班级,我也想显示标题栏。前10个单元格正确显示了标题,当我查看标题开始重复的下一个10个单元格时。照片不重复,所以我不确定字幕的原因。下面是我加载UITableView的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
static NSString *CellIdentifier = @"Cell";
if (indexPath.section == self.objects.count) {
// this behavior is normally handled by PFQueryTableViewController, but we are using sections for each object and we must handle this ourselves
UITableViewCell *cell = [self tableView:tableView cellForNextPageAtIndexPath:indexPath];
return cell;
}
else {
ESPhotoCell *cell = (ESPhotoCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[ESPhotoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
[cell.mediaItemButton addTarget:self action:@selector(didTapOnPhotoAction:) forControlEvents:UIControlEventTouchUpInside];
}
cell.mediaItemButton.tag = indexPath.section;
//The below line of code displays the black square where the photo would be.
cell.imageView.image = [UIImage imageNamed:@"PlaceholderPhoto"];
if (object) {
//The below line displays the users photo on the timeline.
//The following 2 lines is what fills the display cell that shows the photo.
cell.imageView.clipsToBounds = YES;
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
//The below line is what displays the image on the home timeline.
cell.imageView.file = [object objectForKey:kESPhotoPictureKey];
[cell.imageView loadInBackground];
//Below is what I am trying to display the captions
NSString *caption = [object objectForKey:@"caption"];
if (caption != nil) {
cell.captionText.text = [object objectForKey:@"caption"];
}
}
return cell;
}
}
对此问题的任何帮助都会受到赞赏,因为我对移动开发还不熟悉。