我加載視圖,只要用戶旋轉到風景,但是當我在viewDidLoad中使用view.bounds它仍然是肖像。界限何時更新?
這裏,我加載它從通知
- (void)orientationChanged:(NSNotification *)notification
{
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
if (UIDeviceOrientationIsLandscape(deviceOrientation) && !isShowingLandscapeView)
{
[self presentModalViewController:self.graphViewController animated:YES];
isShowingLandscapeView = YES;
} else if (deviceOrientation == UIDeviceOrientationPortrait && isShowingLandscapeView)
{
[self dismissModalViewControllerAnimated:YES];
isShowingLandscapeView = NO;
}
}
,並在viewDidLoad中我使用self.view.bounds初始化一個核心情節graphViewController觸發視圖的代碼。
這是怎麼看起來像
如何解決這個問題的任何提示?
非常感謝
編輯
在viewDidLoad中
// Create graph from theme
graph = [[CPTXYGraph alloc] initWithFrame:self.view.bounds];
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
[graph applyTheme:theme];
CPTGraphHostingView *hostingView = [[CPTGraphHostingView alloc] initWithFrame:self.view.bounds];
hostingView.collapsesLayers = NO; // Setting to YES reduces GPU memory usage, but can slow drawing/scrolling
hostingView.hostedGraph = graph;
[self.view addSubview:hostingView];
如何在屏幕上添加圖形視圖?你是否試圖直接將其添加到窗口? – LucasTizma
[self presentModalViewController:self.graphViewController animated:YES]; – Chris
是的,但在該視圖控制器中,您如何創建和添加圖形視圖。請顯示更多代碼。很明顯,視圖控制器正在旋轉,所以它的子視圖也應該如此。 – LucasTizma