相关疑难解决方法(0)

自定义键盘中的iOS 8.3'UIView-Encapsulated-Layout-Width'

我已经实现了自定义键盘.它在运行iOS 8.2的设备上运行良好.

但是,当我在iOS 8.3设备上运行相同的代码时,我收到以下警告,键盘高度设置不正确:

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) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x15dd1da0 h=-&- v=-&- Keyboard:0x15db2b00.width == UIView:0x15da7b90.width - 320>",
    "<NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>" …
Run Code Online (Sandbox Code Playgroud)

objective-c autolayout ios8 custom-keyboard

11
推荐指数
1
解决办法
2533
查看次数

iOS 8中具有动态高度的自定义inputView

我的自定义inputView for有些麻烦UITextFields.根据用户需要输入的文本UITextField,inputView仅显示所需的字母.这意味着对于短文本,只有一行字母的inputView就足够了,较长的文本可能需要2行甚至3行,因此inputView的高度是变量.

由于我期望性能更好,因此每个textField只使用一个inputView实例.这样创建必须只发生一次,这使得有时需要直接访问inputView更容易.inputView已设置- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField,设置其所需的高度并将显示.

这很有效,但不适用于iOS8.有一些包含inputView的系统视图在更改时不会更新其框架以匹配inputView的边界(第一次工作).

我知道可以通过每个textField使用我的inputView的一个实例来修复.但我问是否有一种推荐/更好的方法来调整框架或将其更改报告给包含视图.也许这是一个iOS8错误,可以修复,直到发布?

以下是重现问题的一些示例代码:

CustomInputView

@implementation CustomInputView

+ (CustomInputView*)sharedInputView{
    static CustomInputView *sharedInstance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedInstance = [[CustomInputView alloc] init];
    });
    return sharedInstance;
}

- (id)init
{
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor greenColor];
    }
    return self;
}

- (void)setupForTextField:(UITextField*)textField{
    CGFloat height;

    if(textField.tag == 1){
        height = 100;
    }else height = 50;

    self.frame = CGRectMake(0, 0, 320, height);
}
@end
Run Code Online (Sandbox Code Playgroud)

TestViewController代码

- (void)viewDidLoad
{ …
Run Code Online (Sandbox Code Playgroud)

ios ios8

9
推荐指数
1
解决办法
3935
查看次数

如何更改iOS自定义键盘的高度?

我一直在研究iOS自定义键盘(在.xib文件中),但我无法在故事板中更改高度.有没有办法在故事板中更改键盘的高度,还是我必须找到一种以编程方式进行操作的方法?

keyboard objective-c ios ios8

6
推荐指数
1
解决办法
3043
查看次数

iOS 8自定义键盘高度从纵向变为横向,然后变为纵向

我们可以在viewdidload中创建像此代码一样的自定义键盘,如Apple开发者网站所示.

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]];
Run Code Online (Sandbox Code Playgroud)

但是,有1个问题.当我们以纵向运行该程序时,自定义键盘的高度约为220.然后我们改为横向.它小于220.奇怪的是,当我回到纵向视图时,高度不再是220,它与景观高度相同.它永远不会回到原来的高度.那么,有没有办法改变我们将添加子视图的视图高度?

iphone keyboard autolayout ios8 ios-app-extension

4
推荐指数
1
解决办法
6085
查看次数

替换自定义键盘中的预测文本源

有没有办法在iOS 8自定义键盘扩展中替换预测文本的来源并在预测文本栏中显示?预测文本栏的类是什么?

非常感谢.我已经阅读了文档,但找不到答案.请帮忙.

keyboard ios swift ios8 ios-app-extension

4
推荐指数
1
解决办法
2181
查看次数

在iOS8自定义键盘中无法获得约束

我在iOS 8中遇到了自动布局的主要问题.我正在使用自定义键盘,但我无法让视图以正确的高度显示.设备上呈现的视图太低,更像是单独的UIImageView的预期高度.我已经设置了约束,如图所示:

XCode截图

但是我一直在日志中得到这个错误,它没有告诉我任何事情(可能是因为我不明白在哪里看):

2014-12-06 19:56:45.095 [40268:12181198] 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:0x600000096940 V:[UIInputView:0x7fe780d3f600(246)]>",
    "<NSLayoutConstraint:0x600000097390 'UIView-Encapsulated-Layout-Height' V:[UIInputView:0x7fe780d3f600(0)]>" …
Run Code Online (Sandbox Code Playgroud)

ios swift ios-app-extension

2
推荐指数
1
解决办法
1861
查看次数