2013-12-18 43 views
0

我希望我的應用只能下載到4英寸屏幕iPhone上。 - 我提交應用程序時,AppStore是否有這樣的限制?根據屏幕大小iOS應用下載限制

如果所有程序員都可以在代碼中提到這種限制,請幫助我該怎麼做?

+0

不,它沒有。 –

+0

這會讓你從App Store中被拒絕。您必須支持這兩種尺寸。 –

回答

0

不幸的是,你不能。 但是,您可以通過在應用程序初始化期間使用設備大小[UIScreen mainScreen] bounds].size發出「不支持設備」 的警報進行限制。 至少我們提示用戶說明,此設備不支持!

0

你不能直接在XCode上做,但你可以檢查設備類型,以知道用戶正在使用哪個設備:在普通iPhone的情況下,你可以顯示一個禮貌的消息。

這是我在應用程序中使用的代碼:

DeviceCheck.h

#define isIPad  ([DeviceCheck getDeviceType] == DeviceTypeIPad) 
#define isIPhone ([DeviceCheck getDeviceType] == DeviceTypeIPhone) 
#define isIPhone5 ([DeviceCheck getDeviceType] == DeviceTypeIPhone5) 

enum { 
    DeviceTypeIPad, 
    DeviceTypeIPhone, 
    DeviceTypeIPhone5 
}; typedef NSUInteger DeviceType; 


@interface DeviceCheck : NSObject 

    + (DeviceType)getDeviceType; 

@end 

DeviceCheck.m

#import "DeviceCheck.h" 

static DeviceType _type = -1; 


@implementation DeviceCheck 

+ (DeviceType)getDeviceType { 

    if(_type == -1) { 
     _type = DeviceTypeIPad; 
     CGFloat pixelHeight = CGRectGetHeight([UIScreen mainScreen].bounds); 

     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){ 
      if (pixelHeight == 480.0f)  { _type = DeviceTypeIPhone; } 
      else if (pixelHeight == 568.0f) { _type = DeviceTypeIPhone5; } 
     } 
    } 

    return _type; 
} 

@end 

現在,在您的應用程序,你可以檢查帶有這種簡單科思的設備:

if(isIPad)   { NSLog(@"I'm an iPad"); } 
else if(isIPhone) { NSLog(@"I'm an iPhone 4/iPhone 4s"); } 
else if(isIPhone5) { NSLog(@"I'm an iPhone 5/iPhone 5c/iPhone 5s"); }