我想将PFObject从VC1传递给VC2。我知道如果我将PFObject从Tableview传递给VC很容易。无论如何,我有一个带有Tableview的VC和带有ImageView的segue to detailVC(1)。在点击图像后,此ImageView将在detailiamgeviewcontroller中显示。(2)我想将pfobject发送到此Controller。但不知道该怎么做。 有什么想法吗?
(1)
if ([segue.identifier isEqualToString:@"showDetaill"])
{
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
PFObject *object = [self.objects objectAtIndex:indexPath.row];
DetailViewController2 *detailViewController = [segue destinationViewController];
detailViewController.objecteditem = object;
}
(2)
- (void)viewDidLoad
{
[super viewDidLoad];
[self.imageviewsecond setImageWithURL:[NSURL URLWithString:[self.objecteditem objectForKey:@"VlajkaURL"]]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
UITapGestureRecognizer *singleTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSingleTap:)];
singleTap.numberOfTapsRequired = 1;
[imageviewsecond addGestureRecognizer:singleTap];
}
- (void)handleSingleTap:(UIGestureRecognizer *)sender
{
[self performSegueWithIdentifier:@"sendi" sender:self];
NSLog(@"image tapped!!!");
}
答案 0 :(得分:1)
按照你已经做的那样做。在视图1中,您要将对象发送到视图2(DetailViewController2
)。在DetailViewController2
中,在prepareForSegue
方法中,您也可以这样做:
if ([segue.identifier isEqualToString:@"sendi"])
{
DetailImageViewController *detailImageViewController = [segue destinationViewController];
detailImageViewController.somePropertyName = self.objecteditem;
}