简体   繁体   中英

Image picker presenting behind the UIView

I've a UIView which is added in front of MainWindow. And I wish to present camera picker in that view. But the camera picker always back of the UIView .

How to bring the picker to front. I've checked bringSubviewToFront: but no effect

Code used for presenting picker

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
        {
            UIImagePickerController * picker = [[UIImagePickerController alloc] init];
            picker.delegate = self;
            picker.sourceType = UIImagePickerControllerSourceTypeCamera;
            picker.allowsEditing=TRUE;

            picker.allowsEditing = true;

            [navController presentViewController:picker animated:YES completion:nil];
        }

And here is the code used to add my view to window.

[self.window addSubview:myView.view];
[myView didMoveToParentViewController:self.window.rootViewController];
[appDelegate.window bringSubviewToFront:myView];

Thanks in advance.

Have you tried it this way?

UIImagePickerController * picker = [[UIImagePickerController alloc] init];
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    picker.delegate = self;
[<yourView> addSubview:picker.view];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM