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];

} 
4

1 回答 1

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);
}

并且还有一种方法可以在项目属性中执行此操作..您可以在项目设置窗口中设置方向

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

于 2012-05-16T18:27:22.453 回答