ストーリーボードのビューコントローラーの1つにサブビューとして追加されたテーブルビューがあります。それぞれが 1 つの行を持つ 6 つのセクションがあります。各行を選択すると、新しいビューコントローラーが開きます。そのための6つの異なるビューコントローラーがあります。ストーリーボードでこれを達成する方法がわかりません。これをストーリーボード経由でバインドする方法はありますか、手動で行う必要があります。どんな助けでも受け入れられます。ありがとう。
3820 次
2 に答える
4
ストーリー ボードでビュー コントローラーを使用performSegueWithIdentifier
する場合は、メソッドを使用します。
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section==0) {
[self performSegueWithIdentifier:@"first" sender:nil];
}
if (indexPath.section==1) {
[self performSegueWithIdentifier:@"second" sender:nil];
}
if (indexPath.section==2) {
[self performSegueWithIdentifier:@"third" sender:nil];
}
if (indexPath.section==3)
{
[self performSegueWithIdentifier:@"fourth" sender:nil];
}
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"first"])
{
friendsViewController=[segue destinationViewController];
}
if([[segue identifier] isEqualToString:@"second"])
{
secondViewController=[segue destinationViewController];
}
if([[segue identifier] isEqualToString:@"third"])
{
thirdViewController=[segue destinationViewController];
}
if([[segue identifier] isEqualToString:@"fourth"])
{
fourthViewController=[segue destinationViewController];
}
}
お役に立てると思います。
于 2012-10-05T09:27:18.303 に答える
1
静的セルを含むテーブルビューがあり、それらすべてがストーリーボードに配置されている場合は、ctrl
ボタンとマウスの左ボタンですべてのセルから必要なViewControllerに簡単にドラッグして、セグエを作成できます。
于 2012-10-05T09:19:47.910 に答える