簡體   English   中英

如何使用Xcode 4.5為iPhone 4和iPhone 5創建Xib

[英]How can I create xibs for both iPhone 4 and iPhone 5 using Xcode 4.5

我已將部署目標設置為iOS 4.3,並使用xib創建了viewcontroller。 但是XCode 4.5僅為iPhone 5(4英寸)創建了xib。 如何為iPhone 4創建單獨的xib?

在視圖屬性檢查器的“模擬度量”部分中,可以選擇3,5英寸或4英寸大小。 選擇3,5“,並調整視圖和子視圖的大小,iOS將自動縮放視圖以適合iPhone 5的屏幕。

在xib中,選擇控制器,然后在屬性窗口中設置要保留的視圖大小。

我也在尋找相同問題的解決方案。 我有一組視圖,這些視圖中有圖像視圖,並且現有圖像在iPhone 5中看起來很糟糕。不幸的是,我們需要支持所有4.3+ iOS版本,除了縮放圖像視圖外,我別無選擇。在兩個不同的iPhone上使用單獨的圖像。 這就是我以前做的

    float height = 480.0f;
    NSString *imageName = @"image640x480";
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        CGSize result = [[UIScreen mainScreen] bounds].size;
        height = result.height;
        imageName = @"image640x568";
    }
    // Set the height of your image view to the height calculated above and use the imageName variable to load the correct image

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM