簡體   English   中英

用鍵盤在iOS 8中模態顯示自定義尺寸ViewController的問題

[英]Issue with presenting custom size ViewController modally in ios 8 with keyboard

我正在使用自定義大小的iPad中的導航控制器以模態顯示視圖控制器,但是當鍵盤顯示時,視圖控制器的框架大小會更改。 它可以在iOS 7上完美運行,但是在iOS 8上運行時卻遇到了這個問題。

顯示視圖的代碼:

UINavigationController *navController = [[UINavigationController alloc]  initWithRootViewController:controllerToShow];
navController.modalPresentationStyle = UIModalPresentationFormSheet;
[[AppDelgate instance].rootViewController presentViewController:navController animated:YES completion:nil];

//in opening viewcontroller class frame is set 
  #define view_height 400
 #define view_width 700

-(void)viewWillAppear:(BOOL)animated{

     if ([UIApplication sharedApplication].statusBarOrientation ==   UIInterfaceOrientationLandscapeLeft || [UIApplication   sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight)    {
          self.navigationController.view.superview.frame = CGRectMake(162, 200, view_width, view_height);
     }else {
       self.navigationController.view.superview.frame = CGRectMake(([AppDelgate instance].rootViewController.view.frame.size.width - 700)/2, 250, view_width, view_height);
     }
}

關於如何解決這個問題的任何想法?

更改的系統視圖私有視圖層次從來都不是一個好主意。

您應該使用現有的自定義演示和過渡技術( UIModalPrestationCustomUIViewControllerTransitioningDelegate )來實現您嘗試使用公共API做什么。

通過添加解決

-(CGSize)preferredContentSize{
   return  CGSizeMake(view_width, view_height);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM