繁体   English   中英

如何旋转UIView?

[英]How do I rotate a UIView?

我完成了本教程: http : //dblog.com.au/iphone-development/iphone-sdk-tutorial-build-your-very-own-web-browser/

现在我想添加一个旋转窗口的功能,但是我找不到能帮助我的解决方案...

希望有人可以在这里为我提供帮助...我正在寻找几个小时,找到了一些代码,但是它们都无法为我工作..也许我做错了...如果有人可以告诉我将代码放在哪里,那会很好哪个文件(请看教程)

非常感谢你

在本教程中,导师在主窗口中使用Web视图,因此在应用程序委托中,我们没有shouldAutorotateToInterfaceOrientation函数。 您需要做的是创建一个新的窗口基础项目,并在新项目中添加UIViewController类型的新类。 在这个新类中,从IB添加一个Web视图,然后在您的应用程序委托中导入新类,将其初始化为

例如,您的新类名称是FirstViewController,然后在应用程序委托中

 #import "FirstViewController"

然后在applicationDidFinishLaunching中

FirstViewController *fvc = [[FirstViewController alloc] init];
[window addSubView:fvc.view];

然后在FirstViewController移除方法评论shouldAutorotateToInterfaceOrientation ,因为它已经存在,但只是评论,也确保在shouldAutorotateToInterfaceOrientation功能有return YES; 那么您将能够旋转视图。

您是否覆盖了shouldAutorotateToInterfaceOrientation方法?

控制器的示例代码:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    // return (interfaceOrientation == UIInterfaceOrientationPortrait);
    retrun YES; // to support all rotation
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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