![](/img/trans.png)
[英]Obj-C, how do I get the height of a sub view to scale, across all iPhone sizes?
[英]Obj-C, how do I turn the iphone simulator to landscape?
過去,我已經設法做到這一點,您可以打開某個視圖,然后模擬器向左轉,然后再回到縱向。
我可以使景觀成為風景,但我必須轉過頭才能看到它。
我正在嘗試Moriatry餅圖 。
這是我在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;
}
}
在Simulator iOS中,轉到菜單硬件,向左旋轉(向右旋轉)!
如果將應用程序/視圖設置為僅在橫向模式下運行,則模擬器將自動切換為橫向模式。 (您可能還必須在plist文件中設置支持的界面方向)。
如果應用程序支持所有方向,則必須使用菜單/鍵盤命令來旋轉它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.