在iOS 8自定义键盘中显示建议栏
答
尝试:(viewDidAppear
是UIInputViewController
子类的方法)
- (void)viewDidAppear {
[super viewDidAppear];
CGFloat _expandedHeight = 250;
NSLayoutConstraint *_heightConstraint = [NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant: _expandedHeight];
[self.view addConstraint: _heightConstraint];
}
警告:写在viewDidAppear:
方法
这是行不通的。日志:
2014-10-01 17:10:38.532 Coloured[7232:308451] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x79829970 V:[UIInputView:0x79b2f660(250)]>",
"<NSLayoutConstraint:0x79824ea0 'UIView-Encapsulated-Layout-Height' V:[UIInputView:0x79b2f660(216)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x79829970 V:[UIInputView:0x79b2f660(250)]>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
尝试不工作。请检查编辑。 – 2014-10-01 11:52:33
确保你在'-viewDidAppear:'中试过了。不应该编辑我的帖子来显示日志(应该注释而不是) – VietHung 2014-10-02 04:01:03
谢谢你!它正在工作 – Jamil 2017-07-05 15:31:20