Reputation: 5
I have created custom keyboard with Objective c and used nib file for Keyboard design, my issue is that when I Change keyboard to my custom Keyboard it appears with some delay, I tried many scenario but not get any Success. Please help me to resolve that, help will be appreciated. Thanks in Advance.
Upvotes: 0
Views: 316
Reputation: 650
If you are using AutoLayout try to layout your subviews manually. For me my keyboard appeared instantly without delay when i quitted AutoLayout. Before I had I had a delay of about one second.
For example:
first row of keyboard: q w e r t z u i o p
q had a leading space of 15 px
p had a trailing space of 15 px
q w e r t z u i o p had a spacing of 5 px and they had the same width
Instead of using constraints, you can easily code it yourself in layoutSubviews of your views KeyboardViewController:
NSUInteger numberOfRows = 4;
CGFloat horizontalSpacing = 5.0;
CGFloat verticalSpacing = 12.0;
CGFloat leadingSpacingFirstRow = 3.0;
CGFloat trailingSpacingFirstRow = 3.0;
CGFloat topPadding = 25.0;
CGFloat bottomPadding = 3.0;
CGFloat width = ( self.bounds.size.width - leadingSpacingFirstRow - trailingSpacingFirstRow - horizontalSpacing * (numberOfButtonsFirstRow - 1) ) / numberOfButtonsFirstRow;
CGFloat height = ( self.bounds.size.height - topPadding - bottomPadding - verticalSpacing * (numberOfRows - 1) ) / numberOfRows;
Now you can place the buttons in your view:
// create row 1
for (NSUInteger i=0; i<numberOfButtonsFirstRow; i++) {
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(leadingSpacingFirstRow + i * width + i * horizontalSpacing, topPadding, width, height)];
[self addSubview:v];
}
This sight might help you the-trials-and-tribulations-of-writing-a-3rd-party-ios-keyboard
Upvotes: 1