2013-10-08 109 views
-1

我開發iphone應用程序。我使用xib作爲設計屏幕。我如何使這個應用程序的iPhone 5和iPhone 4s。請以示例幫助我回復該答案。兼容性問題的iPhone 4和iPhone 5

感謝

+0

這個ipad標籤在這裏做什麼???你的問題似乎沒有問你有關ipad的東西嗎? –

+0

[How to develop or migrate apps for iPhone 5 screen resolution?](http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen - 分辨率) –

回答

0

有針對不同分辨率的設備

1)UI調整3種方法---------------- -----------------第一種方法------------------------------- ------------

-(int)setScreenOf 
    { 
     if([self isPad]) 
     { 
      //return value 
      //code for ipad 
     } 
     else 
     {   
      CGRect screenBounds = [[UIScreen mainScreen] bounds]; 
      if (screenBounds.size.height ==568) //height can be dynamic as per device 
      { 
       //return value 
       // code for 4-inch screen   
      } 
      else 
      { //return value 
       // code for 3.5-inch screen   
      } 
     } 

    } 

2)----------------------------- ------第二種方法-------------------------

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
#define isiPhone5 ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE 

you can make different xib for different device and navigate app according to that. 

    if(IS_IPAD) 
     { 
      startVc=[[Start alloc]initWithNibName:@"start_ipad" bundle:nil]; 
      //xib For ipad 
     } 
     else 
     { 
      if(isiPhone5) 
      { 
       startVc=[[Start alloc]initWithNibName:@"start_iphone" bundle:nil]; 
       //xib for iphone5 
      } 
      else 
      { 
       startVc=[[Start alloc]initWithNibName:@"Start" bundle:nil]; 
       //xib for 3.5 inch device 
      } 

     } 

nav=[[UINavigationController alloc]initWithRootViewController:startVc]; 

3)-------- -----------------------------第三米ethod -----------------

您可以使用單一廈門國際銀行鍼對不同的設備,但它會變得複雜而難以管理,如果你的用戶界面包含得多的圖像。

enter image description here

你可以調整你的UI控件或重新大小的控制使用該授權屬性。 您的UI - 控制將如何生效將由它旁邊實施例的窗口中顯示。

  1. 內在箭頭會讓你的UI控件大大小小按設備 分辨率
  2. 外界將按住特定 角落中心控制。
0

你需要兩個設計中的兩個XIB文件中的一個3.5英寸的視網膜(iPhone 4),另一種是4英寸視網膜(iPhone 5),當你調用廈門國際銀行,你需要檢查的條件。

#define isiPhone5 ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE 
#define isiPhone4 ([[UIScreen mainScreen] bounds].size.height == 480)?TRUE:FALSE 

在constant.h文件中定義上述stattement

,然後檢查您的視圖控制器以下條件時,你推或更改視圖 - 控制

if (isiPhone5) // check wheather a phone is iphone 5 or not 
{ 

    yourViewController *objyourViewController=[[yourViewController alloc]initWithNibName:@"yourViewController_iphone5" bundle:nil]; 
    [self.navigationController pushViewController:objyourViewController animated:YES]; 
} 
else if (isiPhone4) // check wheather a phone is iphone 4 or not 
{ 
    yourViewController *objyourViewController=[[yourViewController alloc]initWithNibName:@"yourViewController_iphone4" bundle:nil]; 
    [self.navigationController pushViewController:objyourViewController animated:YES]; 
} 

我希望這將有助於你

+0

嗨,Maul,我不得不在類或Appdelegate方法中聲明這個東西。 –

+0

在完成所有導入語句後的類中 –

+0

如果要在控制器中添加AppDelegate.h,則仍然可以使用 –

0

入住廈門國際銀行.. enter image description here

Ø NLY上邊和左邊部分啓用..then嘗試它..