prepareForSegue equivalent in WatchKit

后端 未结 4 1920
生来不讨喜
生来不讨喜 2021-01-11 10:07

I have an interface with 2 buttons, both of them call the same interface but with different information. On the traditional interface I use prepareForSegue, but I don\'t kno

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 10:52

    You can do this in two ways:

    In your storyboard you set an identifier in your segue:

    enter image description here

    and then you can use contextForSegueWithIdentifier:

    - (id)contextForSegueWithIdentifier:(NSString *)segueIdentifier {
         if ([segueIdentifier isEqualToString:@"yourIdentifier"]) {
            return aDictionaryWithYourInformation;
         }
    }
    

    Or you can pass information with a context via code, with:

    [self pushControllerWithName:@"YourViewController"
                         context:aDictionary];
    

    This context is a dictionary and you have access to this dictionary in the - (void)awakeWithContext:(id)context

提交回复
热议问题