I want to make a custom keyboard in iOS 8. I want to change the size of it when the phone rotates to landscape mode.
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{
NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
if ((toInterfaceOrientation==UIInterfaceOrientationPortrait) || (toInterfaceOrientation==UIInterfaceOrientationPortrait))
{
[def setObject:@"No" forKey:@"LandScape"];
[def synchronize];
islandscapemode = NO;
NSLayoutConstraint *_heightConstraint =
[NSLayoutConstraint constraintWithItem: self.view
attribute: NSLayoutAttributeHeight
relatedBy: NSLayoutRelationEqual
toItem: nil
attribute: NSLayoutAttributeNotAnAttribute
multiplier: 0.0
constant: 266];
[self.view addConstraint:_heightConstraint];
}
else
{
[def setObject:@"Yes" forKey:@"LandScape"];
[def synchronize];
NSLayoutConstraint *_heightConstraint =
[NSLayoutConstraint constraintWithItem: self.view
attribute: NSLayoutAttributeHeight
relatedBy: NSLayoutRelationEqual
toItem: nil
attribute: NSLayoutAttributeNotAnAttribute
multiplier: 0.0
constant: 266];
[self.view addConstraint:_heightConstraint];
self.view.backgroundColor=[UIColor greenColor];
islandscapemode = YES;
}
// [self determineKeyboardNib:toInterfaceOrientation];
}
But it doesn't work. What should I do?