2012-05-16 84 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); 
} 

来完成,也有办法在项目属性做到这一点。你可以在项目设置窗口中设置方向

希望这能解决问题.. :)