0

誰かが親切に助けてくれるのだろうか、私はiPhone 5の全画面を認識できるようにアプリを調整しようとしていますが、他の画面でもすべて正常に動作しますが、最初の画面で問題が発生し、フェードします上部と下部のバーが見えなくなり、上部は正常に機能しますが、下部は機能しません。iPhone5で動作させるために、コードを手伝ってくれる人はいますか?今のところ、iPhone 5の画面ではバーが高すぎて、フェードアウトしません...

- (void)barwillGo
{

     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
    [UIView animateWithDuration:0.5f
                          delay:0.0f
                        options:UIViewAnimationCurveEaseIn
                     animations:^{

                         CGRect top = CGRectMake(0, -51, 320, 50);

                         if (CGRectEqualToRect(topBar.frame,top))
                         {

                             [topBar setFrame:CGRectMake(0, 0, 320, 50)];
                             [bottomBar setFrame:CGRectMake(0, 430, 320, 50)];

                             }

                         else {
                             [topBar setFrame:CGRectMake(0, -51, 320, 50)];
                             [bottomBar setFrame:CGRectMake(0, 481, 320, 50)];
                         }


                     }
                     completion:nil];
     }
     else {
         [UIView animateWithDuration:0.5f
                               delay:0.0f
                             options:UIViewAnimationCurveEaseIn
                          animations:^{

                              CGRect top = CGRectMake(0, -51, 768, 50);

                              if (CGRectEqualToRect(topBar.frame,top))
                              {

                                  [topBar setFrame:CGRectMake(0, 0, 768, 50)];
                                  [bottomBar setFrame:CGRectMake(0, 974, 768, 50)];

                              }

                              else {
                                  [topBar setFrame:CGRectMake(0, -51, 768, 50)];
                                  [bottomBar setFrame:CGRectMake(0, 1025, 768, 50)];
                              }


                          }
                          completion:nil];
     }
}
4

2 に答える 2

1

bottomBarのCGRect値を3.5インチの画面サイズにハードコーディングしました。

最初のアニメーションブロック内で次のようなものを試してください。

CGRect bounds = topView.superview.bounds;
CGFloat topRectY, bottomRectY;
if(topBar.frame.origin.y == -50){
   topRectY = 0;
   bottomRectY = bounds.size.height - 50;
} else {
   topRectY = -50;
   bottomRectY = bounds.size.height;
}
topBar.frame = CGRectMake(0, topRectY, bounds.size.width, 50);
bottomBar.frame = CGRectMake(0, bottomRectY, bounds.size.width, 50);
于 2013-03-16T04:05:30.280 に答える
0
    CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        [UIView animateWithDuration:0.5f
                              delay:0.0f
                            options:UIViewAnimationCurveEaseIn
                         animations:^{

                             CGRect top = CGRectMake(0, -51, 320, 50);

                             if (CGRectEqualToRect(topBar.frame,top))
                             {

                                 [topBar setFrame:CGRectMake(0, 0, 320, 50)];
                                 [bottomBar setFrame:CGRectMake(0, 430, 320, 50)];

                             }

                             else {
//check device iphone5 or not
                                 if (screenHeight != 568.0f) {
                                     [topBar setFrame:CGRectMake(0, -51, 320, 50)];
                                     [bottomBar setFrame:CGRectMake(0, 481, 320, 50)];
                                 }
                                 else
                                 {
                                     [topBar setFrame:CGRectMake(0, -51, 320, 50)];
                                     [bottomBar setFrame:CGRectMake(0, 569, 320, 50)];
                                 }
                             }


                         }
                         completion:nil];
    }
于 2013-03-16T06:54:40.523 に答える