[英]UIControl sub Class problem in sendActionsForControlEvents
[英]how to check UIControl class orientation?
在我的应用程序中,我使用超类UIControl创建了一个自定义类,并将该类视图添加到window.Now我的问题是我的自定义类视图无法识别方向。当我旋转设备自定义类视图时不会旋转。
是否有任何方法可以旋转自定义类,或者有什么方法可以旋转该自定义视图?
这是我的代码:
- (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];
}
}
请指导我或建议我这样做的方法。
谢谢
您需要将自定义视图添加到视图controller.view,而不是Window:窗口不旋转...
试过这个吗? [UIApplication sharedApplication].statusBarOrientation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.