uiwindow横向模式问题

发布于 2024-10-15 20:34:09 字数 889 浏览 6 评论 0原文

ia uiview compenent 并将其添加到应用程序 uiwindow 中,如下所示。它在纵向模式下工作正常,但当我进入横向模式时,它无法正常工作。它认为 uiwindow 仍然感觉自己处于纵向模式,尽管不是。如何才能以横向模式运行?

谢谢。

MyView* popupView = [[MyView alloc] initWithFrame:CGRectMake(0, 0, 320, 480) url:url sliderType:slidingType html5Flag:_html5Flag];
// 我将框架更改为 CGRectMake(0, 0,480, 320) 但不起作用

[popupView setTitle:self.currentAd.altText];
popupView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5]; 

UIWindow* mainWindow = (((UIWindow*) [UIApplication sharedApplication].delegate).window);   

CGPoint middleCenter = popupView.center;   
CGSize offSize = [UIScreen mainScreen].bounds.size;  

CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.5);   

popupView.center = offScreenCenter; 
[mainWindow addSubview:popupView];    
popupView.center = middleCenter;

i a uiview compenent and add it to application uiwindow like below. it works fine in portrait mode but when i oriante into lanscape mode it does not work properly. it think uiwindow still feels itself in portrait mode although not. how can run in landscape mode?

thanks.

MyView* popupView = [[MyView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)
url:url slidingType:slidingType html5Flag:_html5Flag];
// i change frame to CGRectMake(0, 0,480, 320) but not works

[popupView setTitle:self.currentAd.altText];
popupView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5]; 

UIWindow* mainWindow = (((UIWindow*) [UIApplication sharedApplication].delegate).window);   

CGPoint middleCenter = popupView.center;   
CGSize offSize = [UIScreen mainScreen].bounds.size;  

CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.5);   

popupView.center = offScreenCenter; 
[mainWindow addSubview:popupView];    
popupView.center = middleCenter;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一页 2024-10-22 20:34:09

您是否查看 popupView 自动旋转?您需要在 UIViewController 类中实现此方法:

- (void)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return YES;
}

Is that you view popupView autorized to rotate ? You need yo implement this method in your UIViewController class:

- (void)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return YES;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文