2011-04-26 106 views
0

我完成这个教程: http://dblog.com.au/iphone-development/iphone-sdk-tutorial-build-your-very-own-web-browser/如何旋转UIView?

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

希望有人能帮助我在这里...我正在寻找几个小时,发现了一些代码,但他们都不会为我工作..也许我犯了一些错误......如果有人能告诉我将代码放在哪个文件中(请看教程)

非常感谢你

回答

1

在本教程中,导师是使用在主窗口中的Web视图,所以在应用程序委托我们没有shouldAutorotateToInterfaceOrientation功能。你必须做的是创建一个新的基于窗口的项目,并在新的项目中添加新类的UIViewController类型。在这个新的类从IB和你的应用程序代理进口新类添加Web视图,它初始化为

例如新的类名是FirstViewController然后在应用delegate.m

#import "FirstViewController" 

然后在在applicationDidFinishLaunching

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

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

0

您是否覆盖方法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 
} 
+0

不,我只是按照教程,我该如何使用它?我是一个新手在xcode :( – njaknjak 2011-04-26 13:18:58

+1

教程只能带你到目前为止。你需要搜索Apple Docs'shouldAutorotateToInterfaceOrientation' – 2011-04-26 13:22:11