所以这是我的 mapView 的代码:
self.mapView = [[MKMapView alloc] init];
self.mapView.frame = CGRectMake(0, 70 , self.view.bounds.size.width,
self.view.bounds.size.height);
当我从一个视图控制器推送到这个视图控制器时,它看起来很好。导航栏和地图视图都在正确的位置;但是,当我尝试创建一个从另一个视图控制器直接转到地图视图控制器的按钮时,一切都发生了变化。
地图视图缩小了,现在导航栏不见了..?这是来自另一个 ViewController 的新按钮:
UIImage* image4 = [UIImage imageNamed:@"Near_me_carousel.png"];
_mapButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 18, 26, 26)];
[_mapButton setBackgroundImage:image4 forState:UIControlStateNormal];
[_mapButton addTarget:self action:@selector(MapButton)
forControlEvents:UIControlEventTouchUpInside];
[_mapButton setShowsTouchWhenHighlighted:YES];
[self.view addSubview:_mapButton];
这是方法:
-(void) MapButton {
MapViewController *mapView = [[MapViewController alloc] init];
[self.navigationController presentViewController:mapView animated:YES completion:NULL];
}
我很困惑为什么会这样!有任何想法吗?