不鼓励在分离的视图控制器上显示类似于显示视图控制器的警告

时间:2015-10-27 10:57:50

标签: ios objective-c

当我尝试从相机胶卷中选择图像时,我收到以下警告。 (当我按下按钮相机滚动时,它会选择相册页面,我们可以从手机中选择图像。)

  

在分离的视图控制器上呈现视图控制器是   泄气

我的didFinishLaunchingWithOptions方法是这样的:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


    [application setStatusBarHidden:YES];
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    [userDefault synchronize];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.viewController = [[ViewController alloc] init];
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    self.window.rootViewController = navigation;
    navigation.navigationBarHidden = YES;

    [self.window makeKeyAndVisible];
}

我的相机按钮代码是:

- (void)cameraButtonSelected
{

ELCAlbumPickerController *albumController = [[ELCAlbumPickerController alloc] initWithNibName:nil bundle:nil];
ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initWithRootViewController:albumController];
[albumController setParent:elcPicker];
[elcPicker setDelegate:self];

AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];

[app.viewController presentViewController:elcPicker animated:YES completion:nil];
[self.view.window.rootViewController.navigationController pushViewController:elcPicker animated:YES];
   }

2 个答案:

答案 0 :(得分:0)

在ViewController或ViewDidAppear方法中编写相机方法。

答案 1 :(得分:0)

在这里,您尝试同时展示picker以及推送。

推动你的选择器或呈现它。

如果您在场或从任何视图控制器推送它,那么只需写下:

无论

[self presentViewController:elcPicker animated:YES completion:nil];

或者

[self.navigationController pushViewController:elcPicker animated:YES];