我正在尝试使用iOS应用,一个viewController肖像,一个使用GoogleMap横向的viewController如下:
在实施和测试方面,它显示:
我不确定在iPhone 6 iOS 8.3上运行时会是怎样的。设置设备方向和界面方向似乎必须设置不同的参数。我有
AppDelegate.m
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
ViewControllerA.m
-(void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
ViewControllerB.m
-(void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
isPresented = YES;
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight];
}
viewDidLoad ...
GMSMarker *marker = [[GMSMarker alloc] init];
NSLog(@"assadsd arrived map");
if(latitide!=0.00&&longitude!=0.00) {
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(latitide, longitude);
marker.position = CLLocationCoordinate2DMake(position.latitude, position.longitude);
camera = [GMSCameraPosition cameraWithLatitude:latitide longitude:longitude zoom:12];
}else{
camera = [GMSCameraPosition cameraWithLatitude:22.2855200 longitude:114.1576900 zoom:12];
marker.position = CLLocationCoordinate2DMake(22.2855200, 114.1576900);
}
self.myMapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
请您告诉我第一张照片的工作原理吗?似乎iOS 8.3有一些方向错误,必须重新分配正确的视图宽度和高度,但我不确定它究竟是如何工作的。
答案 0 :(得分:0)
如果您正在使用NavigationController,则创建navigationController子类并覆盖shouldAutorotate方法。