2014-11-06 17 views
0

我提出這是由蘋果公司爲此拒絕了自定義鍵盤因爲它拒絕iOS的自定義鍵盤不給iPad支持

2.10:iPhone應用程序也必須在iPad上運行而無需修改,在iPhone的分辨率,和在2X iPhone 3GS分辨率

我的意圖是開發只爲iPhone(但蘋果有其他想法),但當我檢查在iPad的自定義鍵盤它只覆蓋鍵盤的一半長度,如320寬度。

的事情我做

  • 其次AppCoda教程,但在的OBJ C.開發

  • 沒有用NSAutolayout約束我在廈門國際銀行的處理一切,其中有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.So打開時讓我的鍵盤我要去哪裏錯了?所有的教程都在iPhone中顯示,它似乎也可以在iPad上運行,但不是我的鍵盤。

回答

0

這行代碼解決我的問題

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