Unwind segue doesn't dismiss adaptive popover presentation when not modal

前端 未结 4 1014

Update for iOS 9 beta: Apple may have fixed this for iOS 9. If you work(ed) around this issue for iOS 8, make sure it also works correctly on iOS 9.

In

4条回答
  •  星月不相逢
    2021-02-06 12:24

    It is/must be a behavior of the popOver segue, in normal situations or regularly we need that the popOver keeps in view, if the segue show something important is annoying that we lost that information just because we rotate the device, I guess that that is the reason of that native behavior. So if we want for it to dismiss automaticly we have to make that behaivor by our own, this works:

    in the method - (void)viewDidLoadin the detailViewController.m add this:

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter]
     addObserver:self selector:@selector(orientationChanged:)
     name:UIDeviceOrientationDidChangeNotification
     object:[UIDevice currentDevice]];
    

    then create this method:

    - (void) orientationChanged:(NSNotification *)note{
    UIDevice * device = note.object;
    //CGRect rect = [[self view] frame];
    switch(device.orientation)
    {
        default:
            [self dismissViewControllerAnimated:YES completion:nil];
        break;    }}
    

    You said that in a single view happens what you want, but I've never seen that behavior when I used popOvers.

提交回复
热议问题