iOS: Show Modal View Controller with full screen image

ios, uiimageview

Solution

did you try `[image view setCenter:self.view.center]` that one centres according to screen but if you want to centre to modalCon then replace `self.view` to `modalCon.view`

Problem

I want to show a fullscreen image when a thumbnail is tapped. Right now I'm presenting a modal view controller, but the image is not centered in the screen: Here's the code I'm using in the modal view controller to present the view controller: ``` UIViewController *modalCon = [[UIViewController alloc] init]; modalCon.view.backgroundColor=[UIColor blackColor]; modalCon.view.userInteractionEnabled=YES; UIImageView *imageView = [[UIImageView alloc] initWithFrame:modalCon.view.frame]; imageView.contentMode=UIViewContentModeScaleAspectFit; imageView.image=coverImage.image; [modalCon.view addSubview:imageView]; UITapGestureRecognizer *modalTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissModalView)]; [modalCon.view addGestureRecognizer:modalTap]; [self presentViewController:modalCon animated:YES completion:nil]; ``` How do I get this image centered in the view controller?

Original source