Objective c 如何设置Modalview控制器的中心。有什么解决方案吗?

Objective c 如何设置Modalview控制器的中心。有什么解决方案吗?,objective-c,modalviewcontroller,presentmodalviewcontroller,Objective C,Modalviewcontroller,Presentmodalviewcontroller,但是它不适合屏幕的中央。我可以用Popovercontroller试试这个,我最好用它,但我不能用modalview控制器。我认为这篇文章将对那些试图为modalview设置框架的人有所帮助。添加到您的MaterialDetailsView控制器中 How to set center of the modalview controller to its center of self.view or Appdelegate window.I have sample code.The followi

但是它不适合屏幕的中央。我可以用Popovercontroller试试这个,我最好用它,但我不能用modalview控制器。我认为这篇文章将对那些试图为modalview设置框架的人有所帮助。

添加到您的MaterialDetailsView控制器中

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;
iOS 5+

- (void)viewWillLayoutSubviews {
    [super viewWillLayoutSubviews];
    self.view.superview.bounds = CGRectMake(0, 0, 750, 650);
}