简体   繁体   English

3种不同的故事板,用于不同的设备编程和3种不同的iAd版本

[英]3 different storyboards for different devices programing and 3 different iAd versions

Hi i am having trouble with a 3.5 inch screen for my app , so i though to create another storyboard file for an iPhone 3.5 version though i already had a working iPad and iPhone 4 inch version working . 嗨,我在使用3.5英寸屏幕的应用程序时遇到麻烦,因此尽管我已经可以使用iPad和iPhone 4英寸版本,但尽管我要为iPhone 3.5版本创建另一个故事板文件。 My question is can there be 3 storyboards for each device ?1 for iPhone 4 inch main for 3.5 inch iphone and for iPad and how to recognize iAd height as well got it working for 2 versions iPad and iPhone but can't figure out for 3 heres the code for iAd 我的问题是每台设备都可以有3个故事板吗?1个iPhone 4英寸主屏幕(用于3.5英寸iphone和iPad),以及如何识别iAd高度,使其适用于2个版本的iPad和iPhone,但无法确定3个这是iAd的代码

- (AppDelegate *) appdelegate {
    return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}

-(void) viewWillAppear:(BOOL)animated{
    _UIiAD = [[self appdelegate] UIiAD];
    _UIiAD.delegate = self;
    //checkts whether you are running on iPad,or iphone to get the banner to correct possition
        if ( IDIOM == IPAD ) {
            [_UIiAD setFrame:CGRectMake(0,960,320,50)];
        } else {
            [_UIiAD setFrame:CGRectMake(0,521,320,50)];

    }
    [self.view addSubview:_UIiAD];

}
-(void) viewWillDisappear:(BOOL)animated{
    _UIiAD.delegate = nil;
    _UIiAD=nil;
    [_UIiAD removeFromSuperview];
}

-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
    NSLog(@"ads loaded");
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [_UIiAD setAlpha:1];
    [UIView commitAnimations];
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
    NSLog(@"ads not loaded");
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [_UIiAD setAlpha:0];
    [UIView commitAnimations];
}

need to do it for 3.5 as well and can't figure out as for the hook up about the 3 different storyboard i got this string doing it at my plist file 也需要为3.5做,无法弄清楚关于3种不同故事板的连接,我在我的plist文件中得到了这个字符串

Main storyboard file base name Main storyboard file base name(iPad) should i simply create new string Main storyboard file base name(iPhone) and hook up the storyboard file i created ? 主情节提要文件的基本名称我的主情节提要的文件基本名称(iPad)我是否应该简单地创建新字符串主主情节提要的文件基本名称(iPhone)并连接我创建的情节提要的文件? or can anyone tell me a simpler solution maybe with constrains in Xcode 6 though i still try to figure out how it works thanks ! 或者有人可以告诉我一个更简单的解决方案,也许受Xcode 6的约束,尽管我仍然试图弄清楚它是如何工作的,谢谢!

You don't need to create separate the storyboard for 3.5 inch device. 您无需为3.5英寸设备创建单独的情节提要。 just define below macros globally in your application and you can put the check for various device. 只需在应用程序中全局定义以下宏,就可以对各种设备进行检查。

`#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) `#define IS_IPAD(UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPad)

define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) 定义IS_IPHONE(UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPhone)

define IS_IPHONE_5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0f) 定义IS_IPHONE_5(IS_IPHONE && [[[UIScreen mainScreen]边界] .size.height == 568.0f)

define IS_IPHONE_4 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 480.0f) 定义IS_IPHONE_4(IS_IPHONE && [[[UIScreen mainScreen]边界] .size.height == 480.0f)

define IS_RETINA ([[UIScreen mainScreen] scale] == 2.0f) 定义IS_RETINA([[[UIScreen mainScreen] scale] == 2.0f)

define IDZTrace() NSLog(@"%s", PRETTY_FUNCTION ) 定义IDZTrace()NSLog(@“%s”, PRETTY_FUNCTION

` Just put IS_IPHONE_4 check for 3.5 inch device and apply your concerning logic. `只需将IS_IPHONE_4放在3.5英寸的设备上,然后应用相关逻辑即可。 You can use also use auto layout and constraints. 您还可以使用自动布局和约束。 follow http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1 if you are not clear about the constraint and auto layout concept. 如果您不清楚约束和自动布局的概念,请遵循http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM