我是StackOverflow的新手,也是Objective-C的新手。启动方向不对
我已经试过了几个星期,现在找到了一些能够给我提示做些什么的东西,但是我似乎无法通过这个问题来解决问题。它感觉应该很简单,但...
我遇到了“rootView”控制器旋转的问题。它应该显示在横向上(在我决定使用导航控制器之前它是这么做的)。模拟器以正确的方向显示,但它已经加载了旋转90度左右的视图,以便文本从底部到顶部,侧面读取,因此您必须将头部向左旋转。视图的最左边部分是可见的,但视图的其余部分在屏幕的顶部运行。这是一个大型的程序(我发现,一般来说,使用objective-c,但是尽管如此......),但是这里是我认为重要的代码区域的要点:
在appDelegate中,在实施
// .h file:
UIWindow *window;
wordHelper3ViewController *viewController;
UINavigationController *navigationController;
然后:我创建了一个窗口,我的RootViewController的,和navcontroller
//.m file
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Hide status bar
application.statusBarHidden = YES;
// --- Add the view controller's view to the window and display.
[window addSubview:viewController.view];
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
}
然后我释放所有的这些中的dealloc。
在我的根认为,我这样做:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if (interfaceOrientation == UIInterfaceOrientationLandscapeRight){
return YES;
} else {
return NO;
}
}
我实现以下,看看发生了什么事,而我立即启动获取日志消息:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
if (fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || fromInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"didRotate...");
}
}
除此之外,我不认为我在我的代码中会做任何影响视图的事情。所以现在,在InterfaceBuilder上:
在属性检查器中,根视图和导航控制器都将方向设置为横向。对于rootView,在引用插座下,“视图”被设置为文件的所有者。我也有一个附加到视图的动作(touchUpInside) - 我将它的类更改为UIButton,因为当用户在后台的任何地方点击时我想要resignFirstResponder。
对于navigationController,在Referencing outlets下,它显示从navigationController到我的appDelegate的连接。
在主窗口xib中,导航控制器显示在列表中,并且视图控制器显示为其子视图。
视图控制器也在主窗口的对象列表中显示。
唯一突出给我的是,当我双击窗口对象时,IT在纵向模式下可视化显示。
有没有人有任何想法?
你介意张贴的截图取向问题,你的描述有点不清楚。 – Moshe 2011-01-30 18:02:25
的截图工作... – pereirap 2011-01-30 22:03:30
的截图张贴我的谷歌文档页面上 - 这里的链接: https://docs.google.com/document/d/1kZMPTsqVT6yAdxCa1HPXu0jhZnDa4QOsJ3p9_wqYs5Q/edit?hl=en&authkey=CJf58PEG – pereirap 2011-01-30 22:10:47