简体   繁体   中英

how to check UIControl class orientation?

In my app i have created one custom class with superclass UIControl.and add that class view to window.Now my problem is my custom class view cannot identify the orientation.when i rotate the device custom class view doesnt rotate.

Is there any method to rotate a custom class or is there any way to rotate that custom view?

here is my code:

          - (void) showForView:(UIView *)forView
     {
        NSLog(@"window frame=%@",forView.window);
          if(self.hidden || hiding || !view.superview) {
                     UIWindow *viewWindow=[[UIWindow alloc]init]; 


               viewWindow = forView.window;


    [[NSNotificationCenter defaultCenter] postNotificationName:CustomKeyboardWillShowNotification object:self];

    // remove from old view and add to new view (if necessary)
    if(view.superview && (view.superview != viewWindow)) {
        [view removeFromSuperview];
    }
    if(!view.superview) {
        CGFloat x;

             x = view.bounds.size.width / 2;

                   y = viewWindow.frame.size.height/2.5 + (view.frame.size.height/2);

        self.hiddenCenter = CGPointMake(x, y);
        view.center = hiddenCenter;

    self.view.transform=CGAffineTransformMakeRotation(-(M_PI/2));

        [viewWindow addSubview:view];
            self.autoHideWhenInactive = [[NSUserDefaults standardUserDefaults] boolForKey:kKeyboardAutoHideKey];
    }
}

Please guide me or suggest me the way to do this.

Thank you

您需要将自定义视图添加到视图controller.view,而不是Window:窗口不旋转...

Tried this?. [UIApplication sharedApplication].statusBarOrientation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM