popoverviewController crash on iPhone, works on iPad

前端 未结 2 1918
甜味超标
甜味超标 2021-01-26 22:31

a noob question here:

any ideas why this code:

UIViewController* popoverviewController = [[UIViewController alloc]init];
UIView* popoverView = [[UIView a         


        
2条回答
  •  别那么骄傲
    2021-01-26 22:56

    You cannot use a UIPopoverController with iPhone. U will need to detect which device idiom u are using and present the appropriate viewController type at runtime.

    The project here provides some examples. The basic gist of it is the following:

     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
         /* use iPhone related viewController via either presentModal or via UIViewController containment */
     }else{
         /* Using an iPad use a popoverController */
     }
    

    Good Luck.

提交回复
热议问题