2

viewDidAppear有谁知道退出UIModalTransitionStylePartialCurlsegue时如何避免被击中?

- (IBAction)buttonSelector:(id)sender
{

    // creating object for title screen
    UIStoryboard *storySelection =[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

    // creating object for profile view
    selectorViewController = [storySelection instantiateViewControllerWithIdentifier:@"Verse Selector"];

    // setting the transition style
    selectorViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;

    // performing the segue
    [self presentViewController:selectorViewController animated:YES completion:nil];
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    // testing for a return from segue
    if (selectorViewController != nil)
    {
        // getting the chosen values from the instance
        chosenBook = selectorViewController.chosenBook;

        // setting instance to nil for garbage collection
        selectorViewController = nil;
    }
}
4

2 回答 2

1

编辑

看起来最好的方法是实现一个自定义委托协议,通知呈现视图控制器呈现的视图控制器正在被解除。

于 2013-02-24T22:36:09.953 回答
0

一种方法是将初始视图控制器设置为模态呈现视图控制器的委托。在呈现视图控制器之前:

selectedViewController.delegate = self;
[self presentViewController:selectorViewController animated:YES completion:nil];

然后,在模态视图控制器中,无论哪种方法关闭模态呈现,都直接在原始视图控制器上调用 viewDidAppear:。

- (void)doneButtonPressed:(id)sender
{
    [self.delegate viewDidAppear:NO];
    [self.delegate dismissModalViewControllerAnimated:YES];
}
于 2013-02-24T22:18:03.683 回答