简体   繁体   English

调整UINavigationController ViewControllers NSArray的顺序

[英]Tweaking the order of UINavigationController ViewControllers NSArray

I want to start my app with a 'HomeScreen' that (amongst some other options) displays a button to choose an image and to resume editing with some image from a previous session. 我想用一个“ HomeScreen”启动我的应用程序,该屏幕(除其他一些选项外)显示一个按钮来选择图像并恢复上一个会话中的某些图像。

  • Button: Pick 按钮:选择
  • Button: Edit 按钮:编辑

When choosing "Edit" it will bring the user to an edit view, using Navigation controllers etc. fine so far When choosing "Pick" it will show the iOS imagePickerController etc. 到目前为止,当选择“编辑”时,它将使用导航控制器等将用户带到编辑视图。选择“拾取”时,它将显示iOS imagePickerController等。

but, after selecting an image, I do not want to return to the 'HomeScreen'. 但是,选择图像后,我不想返回到“ HomeScreen”。 When the UIImagePickerController is being dismissed, it will need to 'uncover' the "Edit" view, as if it had been inserted into the 'ViewControllers NSArray', just below the UIImagePickerController. 当关闭UIImagePickerController时,将需要“发现”“编辑”视图,就像它已插入UIImagePickerController下方的“ ViewControllers NSArray”中一样。

The 'Back' button in the 'Edit' stage will ALWAYS bring the user back to the 'HomeScreen', so even if one had entered this screen through the imagePicker, it still will have to return to the 'HomeScreen' 在“编辑”阶段中的“返回”按钮将始终将用户带回到“主屏幕”,因此,即使通过imagePicker进入了该屏幕,它仍然必须返回“主屏幕”。

One of the reasons that the 'HomeScreen' needs to be the back button, is the the app will be FREE app, but at the HomeScreen will be the option to do IAP to unlock more features and more like the 'About' etc... “ HomeScreen”需要是“后退”按钮的原因之一是该应用程序将是免费的,但在HomeScreen上可以选择执行IAP来解锁更多功能,例如“关于”等。 。

So... how can I tweak the order of the Navigation Controller 所以...我该如何调整导航控制器的顺序

or are there better ways to go from A to B to C and back to A (or from A to C and back to A) 或者有更好的方法从A到B再到C再回到A(或从A到C再回到A)

Add a Bar Button Item on the top left hand side of the scene for 'C' (this will override the back button that automatically gets placed there). 在场景的左上角添加一个“ C”的条形按钮项(这将覆盖自动放置在那里的后退按钮)。

Next create an IBAction for that button that does something like this: 接下来,为该按钮创建一个IBAction,其操作如下:

- (IBAction)goToA:(id)sender {
    [self.navigationController popToRootViewControllerAnimated:YES];
} 

inside homeViewController.m it was just a matter of setting up the right things for the segues: dragged in a viewController and wired it up to the 'Edit'-button, InterfaceBuilder creates the segue and gave it the identifier presentImageEditorViewController . homeViewController.m ,只需为homeViewController.m设置正确的问题:将其拖入viewController并将其连接到“编辑”按钮,InterfaceBuilder即可创建segue并为其指定标识符presentImageEditorViewController Then as usual, setup the segues in the implementation file (for convenient, I skipped the part of setting up the imagePicker etc). 然后像往常一样,在实现文件中设置序列(为方便起见,我跳过了设置imagePicker等的部分)。

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"presentImagePickerController"]) {
        [segue.destinationViewController setDelegate:self];
        NSLog(@"Presenting ImagePickerController");
    }
    else if ([segue.identifier isEqualToString:@"presentImageEditorViewController"]) {
        NSLog(@"Presenting ImageEditorController");
    }
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    NSLog(@"Picked some image");
    [self performSegueWithIdentifier:@"presentImageEditorViewController" sender:self];
    [self dismissViewControllerAnimated:YES completion:nil];
}

At the time of selecting an image in the imagePicker, it calls the delegate methode didFinish… and simply setup the segue to the ImageEditorVieController and then dismisses the ImagePickerController , the back button will be just fine in the imageEditor navigationBar 在选择imagePicker中的图像时,它会调用委托方法didFinish…并简单地将设置设置为ImageEditorVieController ,然后关闭ImagePickerController ,在ImagePickerController ,后退按钮就可以了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 管理UINavigationController的视图控制器 - Managing UINavigationController's viewcontrollers 如何在UINavigationController中正确旋转ViewController? - How to properly rotate viewcontrollers in UINavigationController? UINavigationController的viewControllers和childViewControlle之间的区别 - Difference between viewControllers and childViewControlle for UINavigationController 在UINavigationController中设置框架viewcontrollers视图 - set frame viewcontrollers view in UINavigationController UINavigationController由于NSArray变量而崩溃 - UINavigationController crashes due to a NSArray variable 来自UITabBarController中不同UINavigationController的ViewController中的复杂转换 - complicated Transation in ViewControllers from different UINavigationController in UITabBarController 在动画之前修改UINavigationController viewControllers堆栈 - Amending UINavigationController viewControllers stack before animation 我可以更改UINavigationController viewControllers堆栈吗? - Can I change the UINavigationController viewControllers stack? UINavigationController最多只能处理4个Viewcontroller吗? - Can UINavigationController only handle a maximum of 4 Viewcontrollers? 释放UINavigationController内部的ViewControllers表单内存 - Releasing ViewControllers form memory inside a UINavigationController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM