4
我們可以在蘋果開發人員網站中顯示的viewdidload中創建自定義鍵盤。iOS 8的自定義鍵盤高度從肖像,然後到風景,然後回到肖像
self.nextKeyboardButton = [UIButton buttonWithType:UIButtonTypeSystem];
[self.nextKeyboardButton setTitle:NSLocalizedString(@"Next Keyboard", @"Title for 'Next Keyboard' button") forState:UIControlStateNormal];
[self.nextKeyboardButton sizeToFit];
self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.nextKeyboardButton addTarget:self action:@selector(advanceToNextInputMode) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.nextKeyboardButton];
NSLayoutConstraint *nextKeyboardButtonLeftSideConstraint = [NSLayoutConstraint constraintWithItem:self.nextKeyboardButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0];
NSLayoutConstraint *nextKeyboardButtonBottomConstraint = [NSLayoutConstraint constraintWithItem:self.nextKeyboardButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0];
[self.view addConstraints:@[nextKeyboardButtonLeftSideConstraint, nextKeyboardButtonBottomConstraint]];
但是,有1個問題。當我們以縱向方式運行該程序時,自定義鍵盤的高度約爲220.然後我們切換到橫向。它不到220.奇怪的是,當我回到縱向視圖時,高度不再是220,與景觀高度相同。它永遠不會回到原來的高度。那麼,有沒有辦法改變我們將添加子視圖的視圖的高度?
嘿woof - 你如何用鍵盤擴展記錄?我無法使用鍵盤擴展功能將日誌成功打印到控制檯 – Spentak
當您在設備上運行時,更新到最新的Xcode應該可以修復日誌。有時它仍然是壞的,你可以嘗試卸載應用程序 – woof
已經在最新的Xcode沒有成功。也許它只是鍵盤擴展(與其他擴展相比) – Spentak