Вот проблема:
Итак, я создаю пользовательскую клавиатуру iOS на iPad и, естественно, хочу, чтобы она работала на нескольких iPad. Я настроил его так, что UIView сделан в XIB и создан в моем InputViewController. Прямо сейчас, это установлено в кадр, который указан в моем XIB. Я хочу, чтобы клавиатура находилась в нижней трети моего экрана, покрывая ширину экрана, чтобы не было переполнения.
Я попытался настроить кадр в viewDidLoad () в моем InputViewController, в awakeFromNib () в viewDidLayoutSubviews () и viewWillAppear (), но когда я попробовал их, появляется только черный экран.
Вот мой код (представление bibleKeyboardView
)
class KeyboardViewController: UIInputViewController {
// A property to hold reference to a BibleKeyboardView object
var bibleKeyboardView: BibleKeyboardView!
override func viewDidLoad() {
super.viewDidLoad()
// An instance of BibleKeyboardView is added to the controller's root inputView
let nib = UINib(nibName: "BibleKeyboardView", bundle: nil)
let objects = nib.instantiate(withOwner: nil, options: nil)
bibleKeyboardView = (objects.first as! BibleKeyboardView)
guard let inputView = inputView else { return }
inputView.addSubview(bibleKeyboardView)
// controls visibility of the globe key
bibleKeyboardView.setNextKeyboardVisible(needsInputModeSwitchKey)
// adds automatic handle switching to glove key
bibleKeyboardView.nextKeyboardBtn.addTarget(self,
action:
#selector(handleInputModeList(from:with:)),
for: .allTouchEvents)
bibleKeyboardView.delegate = self
let screenBounds = UIScreen.main.bounds
let screenWidth = screenBounds.width
let screenHeight = screenBounds.height
// This is the part that was causing my blank screen
bibleKeyboardView.frame = CGRect(x: 0, y: screenHeight * 0.67, width: screenWidth, height: screenHeight * 0.33)
}
Вот пи c моего представления клавиатуры, если это полезно

Вот пи c клавиатуры, когда я пытаюсь назначить bibleKeyboardView.frame

Любая помощь будет высоко ценится! Это поставило меня в тупик за последние несколько дней.