我是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