我正在製作應用程序,就像設備改變其定向模式時它改變它的視圖一樣。
第一次當視圖是肖像時,它顯示完美的SearchViewController,然後當我旋轉到風景時推動到新的視圖MapView在風景......現在當我再次改變視圖到肖像地圖旋轉到肖像......但它應該做的搜索視圖控制器......還有一件事情,當我挖掘細節泄露按鈕它應該回去搜索視圖控制器...我認爲導航控制器不能在地圖視圖中工作..U導航控制器沒有工作
這是searchViewController
我的代碼部分- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
if(interfaceOrientation == UIInterfaceOrientationPortrait|| inte rfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
}
else {
MapView *mapView = [[MapView alloc] initWithNibName:@"MapView" bundle:nil];
mapView.title = @"Map";
[self.navigationController pushViewController:mapView animated:YES];
return YES;
}
return YES;
}
,這是我的MapView代碼
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
// return (interfaceOrientation == UIInterfaceOrientationLandscapeRight|| UIInterfaceOrientationLandscapeLeft);
if(interfaceOrientation == UIInterfaceOrientationPortrait|| interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
NSLog(@"hi Potrait");
[self.navigationController popViewControllerAnimated:NO];
return YES;
}
else {
}
return YES;
}
請格式化你的代碼下一次。它使它更具可讀性。 – PengOne