Obj-C,如何将iphone模拟器转为风景?

时间:2011-01-18 14:18:48

标签: iphone objective-c xcode

过去我设法做到这一点,你打开某个视图,然后模拟器向左转,然后再回到肖像。

我可以制作自己的视野,但我必须转过头来看它。

我正在尝试Moriatry piechart

这是我在viewWillAppear

中使用的代码
CGRect myImageRect = CGRectMake(0.0f, 20.0f, 460.0f, 280.0f); 
BNPieChart* chart = [[BNPieChart alloc] initWithFrame:myImageRect];
[chart addSlicePortion:0.1 withName:@"Orange 10%"];
[chart addSlicePortion:0.2 withName:@"Fandango 10%"];
[chart addSlicePortion:0.1 withName:@"Blue 10%"];
[chart addSlicePortion:0.1 withName:@"Cerulean 10%"];
[chart addSlicePortion:0.3 withName:@"Green 10%"];
[chart addSlicePortion:0.1 withName:@"Yellow 10%"];
[chart addSlicePortion:0.1 withName:@"Pink 10%"];
[self.view addSubview:chart];

这些是我试过的......也许我还没有正确使用它们?

PieChartViewController *nextController = [[[PieChartViewController alloc] 
  initWithNibName:@"PieChartView" bundle:nil] autorelease];
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] 
  delegate];

CGAffineTransform newTransform = 
  CGAffineTransformMake(0.0,1.0,-1.0,0.0,0.0,0.0);         
nextController.view.transform = newTransform;
[nextController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];

[delegate.graphNavController pushViewController:nextController animated:YES];

这就是..

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)
  interfaceOrientation {
   return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
   interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

而且......

- (void)viewDidLoad {
[super viewDidLoad];

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];   
[[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(didRotate:)
    name:@"UIDeviceOrientationDidChangeNotification" 
    object:nil];    
}

- (void) didRotate:(NSNotification *)notification { 
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

  if (orientation == UIDeviceOrientationLandscapeLeft || 
    orientation == UIDeviceOrientationLandscapeRight) {
    return;
  }

}

2 个答案:

答案 0 :(得分:1)

在模拟器iOS中,转到菜单硬件,向左旋转(向右旋转)!

答案 1 :(得分:0)

如果应用程序/视图设置为仅在横向运行,则模拟器将自动切换到横向。 (您可能还需要在plist文件中设置支持的接口方向。)

如果应用支持所有方向,则必须使用菜单/键盘命令旋转它。