2012-05-16 114 views
1

我需要從狀態欄頂部將表格視圖設置爲以橫向模式爲中心,但表格視圖會自動變爲水平,即從右向左。我究竟做錯了什麼?這裏是我的代碼表視圖變爲水平

- (IBAction)pressToGetTableview:(id)sender 
{ 
tableViewhavingOptions.frame =self.view.frame; 
tableViewhavingOptions.center = CGPointMake(self.view.center.x - 
CGRectGetWidth(self.view.frame), self.view.center.y); 
[self.view.superview addSubview: tableViewhavingOptions]; 

[UIView beginAnimations: nil context: NULL]; 
[UIView setAnimationDuration:1.0]; 
[UIView setAnimationDelegate: self]; 
[UIView setAnimationDidStopSelector: @selector(pushAnimationDidStop:finished:context:)]; 
tableViewhavingOptions.center = self.view.center; 
self.view.center = CGPointMake(self.view.center.x + CGRectGetWidth(self.view.frame), self.view.center.y); 
[UIView commitAnimations]; 

} 

回答

0

檢查,以查看該視圖 - 控制

這種取向可以通過使用

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations.. use specified orientations that you want to see in the view 

    return (interfaceOrientation != UIInterfaceOrientationLandscapeLeft || interfaceOrientation != UIInterfaceOrientationLandscapeRight); 
} 

來完成,也有辦法在項目屬性做到這一點。你可以在項目設置窗口中設置方向

希望這能解決問題.. :)