How to detect Orientation Change in Custom Keyboard Extension in iOS 8?

后端 未结 10 1890

In Custom Keyboard Extension , we can\'t use

`didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation` 

and

10条回答
  •  一生所求
    2020-12-04 18:21

    - (void)updateViewConstraints {
        [super updateViewConstraints];
    
        // Add custom view sizing constraints here
        if (self.view.frame.size.width == 0 || self.view.frame.size.height == 0)
            return;
    
        [self.inputView removeConstraint:self.heightConstraint];
        CGSize screenSize = [[UIScreen mainScreen] bounds].size;
        CGFloat screenH = screenSize.height;
        CGFloat screenW = screenSize.width;
        BOOL isLandscape =  !(self.view.frame.size.width ==
                          (screenW*(screenWscreenH)));
        NSLog(isLandscape ? @"Screen: Landscape" : @"Screen: Potriaint");
        self.isLandscape = isLandscape;
        if (isLandscape) {
            self.heightConstraint.constant = self.landscapeHeight;
            [self.inputView addConstraint:self.heightConstraint];
        } else {
            self.heightConstraint.constant = self.portraitHeight;
            [self.inputView addConstraint:self.heightConstraint];
        }
    
        //trigger default first view
        [btn_gif sendActionsForControlEvents: UIControlEventTouchUpInside];
    }
    

提交回复
热议问题