开发者

Obj-C, how do I turn the iphone simulator to landscape?

I have managed to do this in the past, where you open a certain view and the simulator turns to the left and then back to portrait afterwards.

I can make my view landscape, but I have to turn my head to see it.

I'm trying the Moriatry piechart.

Heres the code I'm using in 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];

These are what I've tried.... Perhaps I haven't used them correctly ???

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

And this..

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

And ...

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

}


In the Simulator iOS, go to menu Hardware, Rotate to left(Rotate to right)!


If the app/view is set to run only in landscape then the simulator will switch to landscape automatically. (You may also have to set the supported interface orientations in your plist file).

If the app supports all orientations you'll have to use the menu/key commands to rotate it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜