ストーリーボードとセグエを使用しています。「連絡先リスト」(tableView) から「プロフィール ビュー」(ScrollView) に切り替えたい。
3 つの質問:
- これはこれを行うための最良の方法(よりクリーンで美しい)ですか?& どうして ?
- 私がこれを行うとき: 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];
}
}