我正在使用故事板和转场。我想从“联系人列表”(tableView)切换到“个人资料视图”(ScrollView)。
三个问题:
- 这是做到这一点的最佳方式(更干净、更漂亮)吗?& 为什么 ?
- 当我这样做时: ProfileViewController *aProfileView = (ProfileViewController *)[segue destinationViewController]; 这是实例化一个新视图吗?(就像它会创建 2 个配置文件视图)。
- 我需要清理(删除某处的“个人资料视图”吗?)还是单独使用导航控制器进行清理?
// 代码
- (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];
}
}