MappleHero commented on issue #2103: Screen orientation problem with iPad version of our app URL: https://github.com/apache/incubator-weex/issues/2103#issuecomment-459940605 The way we try to solve this problem is very complicated. In two steps In the first step, the Native side hooks the viewDidLoad method of the WXBaseViewController of the Weex page, adding a monitor for screen rotation. ``` [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onDeviceOrientationChange) name:UIDeviceOrientationDidChangeNotification object:nil]; ``` ``` - (void)onDeviceOrientationChange { if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) { // 不起作用 // [self.view setNeedsLayout]; // [self.view layoutIfNeeded]; // [self.view.subviews[0] layoutIfNeeded]; // [self.view.subviews[0] setNeedsLayout]; self.view.subviews[0].frame = CGRectMake(self.view.subviews[0].frame.origin.x, self.view.subviews[0].frame.origin.y, GKT_SCREEN_WIDTH, GKT_SCREEN_HEIGHT); self.view.subviews[0].subviews[0].frame = CGRectMake(self.view.subviews[0].subviews[0].frame.origin.x, self.view.subviews[0].subviews[0].frame.origin.y, GKT_SCREEN_WIDTH, GKT_SCREEN_HEIGHT); } else { self.view.subviews[0].frame = CGRectMake(self.view.subviews[0].frame.origin.x, self.view.subviews[0].frame.origin.y, GKT_SCREEN_WIDTH, GKT_SCREEN_HEIGHT); self.view.subviews[0].subviews[0].frame = CGRectMake(self.view.subviews[0].subviews[0].frame.origin.x, self.view.subviews[0].subviews[0].frame.origin.y, GKT_SCREEN_WIDTH, GKT_SCREEN_HEIGHT); } } ```  Because Weex can't dynamically update the page frame,native side manual update the WXRootView and WXView frame. The second step is to listen to the notification on the Weex side and modify the page frame. But this method is not elegant, I hope there is a better way.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
