我正在使用字典用对象填充tableview。表视图单元格设置为字幕,此字典中的两个数组用于显示tableview(标题和子)的数据。现在我对如何将此字典中的其余数组发送到下一个"详细视图"感兴趣。我正在使用Parse来存储这个字典数据。我只需要在激活单元格时在我的详细信息中显示来自同一数据库的另外3个字段。感谢
答案 0 :(得分:0)
如果我理解了您的问题,您希望在detail view
中显示其他数组的其余数据。
使用表格视图“delegate method
”的didSelectRowAtIndexPath
。这里将您想要用作Detail View
的控制器分配到Controller
中,为此Detail Controller
分配您获取的单元格索引的信息,然后推送到此详细视图。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailController *detailVC=[[UIControllerView alloc] initWithNibName:@"DetailController" bundle:nil];
detailVC.textFieldOne.text=[self.arrayOne objectAtIndex:indexPath.row];
detailVC.textFieldTwo.text=[self.arrayTwo objectAtIndex:indexPath.row];
detailVC.textFieldThree.text=[self.arrayThree objectAtIndex:indexPath.row];
[self.navigationController pushViewController:detailVC animated:YES];
}
答案 1 :(得分:0)
我看到你正在使用故事板。
尝试与Key-Value-Coding
上的值prepareForSegue
签名:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.destinationViewController isKindOfClass: [BookDetailViewController class]]) {
BookDetailViewController *destination = segue.destinationViewController;
SEL selector = NSSelectorFromString(@"setFile:");
if ([destination respondsToSelector:selector]) {
NSIndexPath *indexPath = [self.bookstableview indexPathForCell:sender];
PFObject * object = [Booksarray objectAtIndex:indexPath.row];
PFFile *file = [object objectForKey:@"BooksTableView"];
[destination setValue:file forKey:@"file"];
}
}
}
在didSelectRow上执行segue之前尝试删除对deselectRowAtIndexPath:
的调用。如果您不想显示所选行,则可以在“参数”检查器中对其进行编辑,从而在故事板视图中禁用"Show selection on touch"
的{{1}}。
答案 2 :(得分:0)
显示PFObject
的图像:
PFQuery *query = [PFQuery queryWithClassName:@"nameOfParseClass"];
NSArray *objectsPFFounded=[NSArray arrayWithArray:[query findObjects]];
int i=0;
while (i<count){
PFFile *ImageFile = [objectsPFFounded objectAtIndex:i][@"nameOfImageObjectKey"];
[ImageFile getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
if (!error) {
//HERE YOU GOT THE IMAGE
UIImage *image=[UIImage imageWithData:imageData]
}
}];
i++;
}