goffioul commented on issue #1231:
URL: https://github.com/apache/cordova-ios/issues/1231#issuecomment-1510250054

   FYI, I managed to work around the issue by using the following in one of my 
plugins. It's not pretty, but does the job.
   
   ```
   // Add layout constraints to a view (usually a child) to fit and
   // center it onto another view (usually a parent).
   + (void) constrainView:(UIView*)v1 to:(UIView*)v2;
   {
       v1.translatesAutoresizingMaskIntoConstraints = NO;
       [NSLayoutConstraint activateConstraints:@[
           [NSLayoutConstraint constraintWithItem:v1 
attribute:NSLayoutAttributeWidth
               relatedBy:NSLayoutRelationEqual toItem:v2 
attribute:NSLayoutAttributeWidth multiplier:1 constant:0],
           [NSLayoutConstraint constraintWithItem:v1 
attribute:NSLayoutAttributeHeight
               relatedBy:NSLayoutRelationEqual toItem:v2 
attribute:NSLayoutAttributeHeight multiplier:1 constant:0],
           [NSLayoutConstraint constraintWithItem:v1 
attribute:NSLayoutAttributeCenterY
               relatedBy:NSLayoutRelationEqual toItem:v2 
attribute:NSLayoutAttributeCenterY multiplier:1 constant:0],
           [NSLayoutConstraint constraintWithItem:v1 
attribute:NSLayoutAttributeCenterX
               relatedBy:NSLayoutRelationEqual toItem:v2 
attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]
       ]];
   }
   
   - (void) pluginInitialize
   {
       // Dirty trick to work around splashscreen problem when rotating the 
screen.
       // Look into the view hierarchy for the CDVLaunchScreen and add layout 
contraints
       // to make the various layers to fit/center onto each other.
       [self.viewController.view.subviews enumerateObjectsUsingBlock:^(UIView 
*view, NSUInteger idx, BOOL *stop) {
           if (! [view isKindOfClass:WKWebView.class]) {
               [<myplugin> constrainView:view to:self.viewController.view];
               [<myplugin> constrainView:view.subviews[0] to:view];
               *stop = YES;
           }
       }];
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to