【问题标题】:iOS custom keyboard rejected since it does not give iPad SupportiOS 自定义键盘被拒绝,因为它不支持 iPad
【发布时间】:2014-12-21 01:33:51
【问题描述】:

我提交了一个自定义键盘,因此被苹果拒绝了

2.10:iPhone 应用程序还必须无需修改即可在 iPad 上以 iPhone 分辨率和 2X iPhone 3GS 分辨率运行

我的意图是只为 iPhone 开发(但苹果有其他想法),但是当我检查 iPad 中的自定义键盘时,它只覆盖了键盘长度的一半,比如 320 宽度。

我做过的事情

  • 遵循 AppCoda 教程,但使用 Obj C 开发。

  • 没有使用 NSAutolayout 约束作为我在 XIB 中处理的所有内容,其宽度为 320,高度为 220

  • 检查了所有 iPhone 型号的键盘,除 iPad 外,它工作正常

我试过这段代码

   UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
topView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background"]];

UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
[leftButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[leftButton setTitle:@"right " forState:UIControlStateNormal];

[topView addSubview:leftButton];
[self.view addSubview:topView];

NSLayoutConstraint *topC = [NSLayoutConstraint constraintWithItem:leftButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:topView attribute:NSLayoutAttributeTop multiplier:1.0 constant:1.0];

NSLayoutConstraint *rightC = [NSLayoutConstraint constraintWithItem:leftButton attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:topView attribute:NSLayoutAttributeRight multiplier:1.0 constant:1.0];

 NSLayoutConstraint *bottomC = [NSLayoutConstraint constraintWithItem:leftButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:topView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-1.0];

[topView addConstraints:@[topC,rightC,bottomC]];

我得到了这个输出ScreenShot。这是我在 iPad 中打开键盘时得到的确切布局。那么我哪里出错了?所有教程都显示在 iPhone 中,它似乎也适用于 iPad,但不适用于我的键盘。

【问题讨论】:

    标签: ios objective-c iphone ios8 custom-keyboard


    【解决方案1】:

    这行代码解决了我的问题

    self.customView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-21
      • 1970-01-01
      • 2016-11-27
      • 1970-01-01
      • 2011-02-03
      • 1970-01-01
      • 2013-06-06
      • 2016-09-17
      相关资源
      最近更新 更多