我正在使用Storyboards&塞格斯。我想从“Contacts List”(tableView)切换到“Profile view”(ScrollView)。
三个问题:
//代码
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showProfileSelected"])
{
// Get the Selected raw
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
Profile *selectedProfile = [self.profilesTable objectAtIndex:indexPath.row];
// Using segue --> Send the current selected profile to "ProfileView"
ProfileViewController *aProfileView = (ProfileViewController *)[segue destinationViewController];
aProfileView.currentProfile = selectedProfile;
}
}
//其他方法:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showProfileSelected"])
{
// Get the Selected raw
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
Profile *selectedProfile = [self.profilesTable objectAtIndex:indexPath.row];
// Using segue --> Send the current selected profile to "ProfileView"
[segue.destinationViewController setCurrentProfile:selectedProfile];
}
}
答案 0 :(得分:1)
你的第一个例子很好。您没有创建任何内容,只是获取对目标控制器的引用。设置这样的变量允许您在目标视图控制器上设置多个属性,而无需反复投射。
所以,回答你的具体问题: