2013-03-16 35 views
0

我想知道是否有人可以協助我,我正在嘗試調整我的應用程序,以便它可以識別iPhone 5的全屏幕,但它現在可以在其他屏幕上正常工作,但是我的初始屏幕我遇到了問題,因爲我淡入淡出頂部和底部的酒吧,頂部工作正常,但底部沒有,任何人都可以幫助我的代碼來幫助我在iPhone 5上工作嗎?至於現在,酒吧是對iPhone 5的屏幕上太高,不淡出了人們的看法...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]; 
    } 
} 

回答

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); 
+0

精湛,感謝你,是一個很好的解決方案 - 真的再次感謝你幫我,謝謝:) – user1695971 2013-03-16 20:58:35

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]; 
    } 
+0

NANNAV嗨 - 這種解決方案不過,iPhone 5上的酒吧的起始位置進一步上升,尼克C解決方案工作,但我也要感謝你的幫助。 – user1695971 2013-03-16 20:59:17