1

私はUIViewControllers一緒にリンクされている2つを持っています。

最初のものUIViewControllerには4つUIButtonsあり、そのすべてが私を2番目のものに連れて行ってくれUIViewControllerます。

ただし、クリックしたボタンによって内容が変わるはずです。これどうやってするの?

4

1 に答える 1

5

各ボタンに一意のタグを付けprepareForSegue:sender:、クリックしたボタンのタグを確認できる方法を使用して、それに応じてコンテンツを変更します。

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
   UIButton *buttonSender = (UIButton *)sender;
   NSLog(@"Tag of the button tag selected = %d", buttonSender.tag);

   switch (buttonSender.tag) {
        case 1:
            // Content if button 1 was clicked.
            break;
        case 2:
            // Content if button 2 was clicked.
            break;
        case 3:
            // Content if button 3 was clicked.
            break; 
        case 4:
            // Content if button 4 was clicked.
            break;   
        default:
            break; 
   }
}
于 2013-03-13T08:50:21.353 に答える