IOS 8 SplitViewController Simulator portrait iPhone detailView back button issue

This is an assignment for the Stanford iPhone Programming Course. The purpose of this program is to view photos in TableViewControllers and display them in ImageViewController.

The source code was written in iOS 7, so it had two storyboards for the iPhone and iPad. The former uses the tabViewController, and the latter uses the splitViewController.

Since iOS 8 allows us to use splitViewController on both the iPhone and iPad, I just delete the iPhone storyboard and use the iPad as a universal layout. My folding plan is as follows: Oh, I can’t post the layout image here, not enough reputation. Click here to see the storyboard.

I installed two segues that link the two tableViewController with the lowest navigationViewController with the " Show Detail ". And just like in the Xcode "Master Details Application" template, I set splitViewController to delegate myself, and the leftBarButtonItem of my detailViewController (ImageViewController) control to display the ModelButtonItem in appDelegate .

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
    UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
    UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
    navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;
    splitViewController.delegate = self;
    return YES;
}

Problem is in iPhone portrait mode. In the upper left corner of the ImageViewController, the "Wizard" button does not appear back . In iPad mode, everything is working fine.

I am linking my code here: code for this program . Hope someone can help. Thank!

+4
2

segue () ImageViewController (.. ).

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

    // Need a back button to appear when not in split view i.e. iPhone mode
    // Wire up to unwind segue action
    if (!self.splitViewController) {
        UIImage *image = [UIImage imageNamed:@"ImageViewControllerBarBackIndicatorDefault"];
        UIBarButtonItem *btnBack = [[UIBarButtonItem alloc]
                                initWithImage:image
                                style:UIBarButtonItemStylePlain
                                target:self
                                action:@selector(OnClick_btnBack:)];
        self.navigationItem.leftBarButtonItem = btnBack;
    }
}

-(IBAction)OnClick_btnBack:(id)sender {
    [self performSegueWithIdentifier:@"unwind" sender:self];
}

#pragma Unwind Segue

- (BOOL)canPerformUnwindSegueAction:(SEL)action
             fromViewController:(UIViewController *)fromViewController
                     withSender:(id)sender {
    return YES;
}

- (IBAction)unwindFromImageViewController:(UIStoryboardSegue *)unwindSegue {
    [self dismissViewControllerAnimated:YES completion:nil];
}
+1

. http://nshipster.com/uisplitviewcontroller/, . , .

. , .

if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
    self.navigationController?.pushViewController(settingsViewController, animated: true)
} else {
    self.detailViewController?.setViewControllers([settingsViewController], animated: false)
}
0

All Articles