1

このビューには 3 つの UIButton があり、それぞれが 1 つの VC にプッシュするセグエ識別子を持っています。

これがセグエを準備するための私のコードです

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"Button 1"]) {
        [[segue destinationViewController] setBudgetOrderingViewController:self];
    } else if ([segue.identifier isEqualToString:@"Button 2"]) {
        [[segue destinationViewController] setBudgetOrderingViewController:self];
    } else if ([segue.identifier isEqualToString:@"Button 3"]) {
        [[segue destinationViewController] setBudgetOrderingViewController:self];
    }
}

destinationVC に destinationVC をロードするセグエ識別子を知る方法はありますか?

ありがとう。

4

2 に答える 2

1
//Declare a string Property in Destination View Controller
@property (strong, nonatomic) NSString *Segue_Listner;

//In Source ViewController perform segue method
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if ([[segue identifier]isEqualToString:@"destinationVC"]) {
        DestinationVC *dvc = [segue destinationViewController];
        dvc.Segue_Listner = @"somevalue";
 }

ビュー コントローラ全体を渡すことは問題ありませんが、ビュー コントローラ オブジェクトのサイズが大きすぎる場合は注意が必要です。また、destinationVC プロパティを弱いものとして宣言してください (VIEWCONTROLLER を渡し、それがまだメモリ内にある場合のみ)、つまりモーダルに表示します。

文字列プロパティを安全に宣言し、previous/SourceVC で設定することをお勧めします。

于 2015-11-18T23:27:04.507 に答える