How to set center of the modalview controller to its center of self.view or Appdelegate window.I have sample code.The following code is presenting modalview at the right corner of the screen not at the center of the screen.
MaterialDetailsViewController *materialDetails =[[MaterialDetailsViewController alloc]initWithNibName:NSLocalizedString(@"MaterialDetailsViewController",nil) bundle:nil];
materialDetails.view.frame = CGRectMake(0, 0, 750, 650);
materialDetails.modalPresentationStyle = UIModalPresentationFormSheet;
materialDetails.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; //transition shouldn't matter
[self presentViewController:materialDetails animated:YES completion:nil];
materialDetails.view.superview.frame = CGRectMake(self.view.superview.center.x - (750/2),
self.view.superview.center.y - (650/2),
750,650);
I tried to set the modalview frame center to self.view.center in MaterialDetailsViewController class like below
AppDelegate *delegate = [AppDelegate sharedInstance];
self.view.center = delegate.window.center;
但它不适合屏幕的中心。我可以用 Popovercontroller 试试这个我可以做到最好,但我无法用 modalview 控制器进行管理。我认为这篇文章对那些努力的人会有所帮助设置模态视图的框架。