Issue with device orientation and UIView during startup

廉价感情. 提交于 2019-12-02 10:18:57
Parvendra Singh
 you have to declaration below and all give them in viewDidLoad but frame give in
 this code  


-(void)viewWillAppear:(BOOL)animated
 {

   [self willAnimateRotationToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:1.0];

   UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;

   if(orientation == UIInterfaceOrientationLandscapeRight || orientation == UIInterfaceOrientationLandscapeLeft)
   {
     [self setFrameForLeftAndRightOrientation];
   }
   else if(orientation == UIInterfaceOrientationPortrait )
   {
     [self setFrameForPortraitAndUpsideDownOrientation];
   }
 }

  - (void)willAnimateRotationToInterfaceOrientation:
    (UIInterfaceOrientation)toInterfaceOrientation
      duration:(NSTimeInterval)duration
    {
            if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
            toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
           {
             [self setFrameForLeftAndRightOrientation];
           }
           else if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
           {
             [self setFrameForPortraitAndUpsideDownOrientation];
           }
    }

-(void)setFrameForLeftAndRightOrientation
{
     if(IS_IPAD)
     {

     }
     else if(IS_IPHONE)
     {

        if ([[UIScreen mainScreen] bounds].size.height == 568)
       {


       }
       else
      {

      }
    }

}

 -(void)setFrameForPortraitAndUpsideDownOrientation
 {
   if(IS_IPAD)
    {

     }
    else if(IS_IPHONE)
    {


    if ([[UIScreen mainScreen] bounds].size.height == 568)
    {


    }
    else
    {

    }
}

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!