【问题标题】:How to make app views compatible with iPhone 6 and 6 plus如何使应用程序视图与 iPhone 6 和 6 plus 兼容
【发布时间】:2014-10-18 11:37:12
【问题描述】:

我有 XIB 项目(新闻应用)所以它支持(iPhone 4 + 5 + 5s)

我想兼容 iPhone 6 和 6 plus

所以我创建了新文件 Xib,现在我有 5 个这样的 Xib 文件:

MainViewController.xib

MainViewController_568.xib

MainViewController_667.xib

MainViewController_736.xib

所以当我想通过按钮从视图转移到另一个视图时,我下了这个命令:-

- (IBAction)MainViewController:(UIButton *)sender {
    MainViewController *YourApp = [[MainViewController alloc] init];
    if (self.view.bounds.size.height >= 667)
        YourApp = [[MainViewController alloc] initWithNibName:@"MainViewController_667" bundle:nil];
    else
    if (self.view.bounds.size.height >= 568)
        YourApp = [[MainViewController alloc] initWithNibName:@"MainViewController_568" bundle:nil];
    else
        YourApp = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];

    //favController.parent = self;
    [self presentModalViewController:YourApp animated:NO];
    [YourApp release];
    //PP_RELEASE(YourApp);
}

但它没有响应。

【问题讨论】:

  • 苹果提供了自动布局使用

标签: ios ios7


【解决方案1】:

请使用此代码

- (IBAction)MainViewController:(UIButton *)sender {
MainViewController *YourApp = [[MainViewController alloc] init];
if (self.view.bounds.size.height == 736)
    YourApp = [[MainViewController alloc] initWithNibName:@"MainViewController_736" bundle:nil];
else if (self.view.bounds.size.height == 667)
    YourApp = [[MainViewController alloc] initWithNibName:@"MainViewController_667" bundle:nil];
else if (self.view.bounds.size.height == 568)
    YourApp = [[MainViewController alloc] initWithNibName:@"MainViewController_568" bundle:nil];
else
    YourApp = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];

//favController.parent = self;
[self presentModalViewController:YourApp animated:NO];
[YourApp release];
//PP_RELEASE(YourApp);

}

【讨论】:

    【解决方案2】:

    试试这个代码,它可能对你有帮助

    - (IBAction)MainViewController:(UIButton *)sender 
    {
        MainViewController *YourApp = [[MainViewController alloc] init];
        if ( [UIScreen mainScreen].bounds.size.height == 736)
            YourApp = [[MainViewController alloc] initWithNibName:@"MainViewController_736" bundle:nil];
        else if ([UIScreen mainScreen].bounds.size.height == 667)
             YourApp = [[MainViewController alloc] initWithNibName:@"MainViewController_667" bundle:nil];
        else if ([UIScreen mainScreen].bounds.size.height == 568)
             YourApp = [[MainViewController alloc] initWithNibName:@"MainViewController_568" bundle:nil];
        else
             YourApp = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
    
       //favController.parent = self;
      [self presentModalViewController:YourApp animated:NO];
      [YourApp release];
      //PP_RELEASE(YourApp);
    }
    

    【讨论】:

      猜你喜欢
      • 2014-11-04
      • 1970-01-01
      • 2014-12-05
      • 1970-01-01
      • 2015-02-09
      • 1970-01-01
      • 2016-02-02
      • 2015-03-25
      • 2014-11-13
      相关资源
      最近更新 更多