Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 切换UIButton时,地图视图为';t整理整个屏幕_Ios_Objective C_Mkmapview - Fatal编程技术网

Ios 切换UIButton时,地图视图为';t整理整个屏幕

Ios 切换UIButton时,地图视图为';t整理整个屏幕,ios,objective-c,mkmapview,Ios,Objective C,Mkmapview,我不熟悉在iOS中使用MapView,以下是我的情况: 当我切换附近的按钮时,它会将我重定向到地图视图: 然后,当我切换列表视图按钮时,它将显示一个带有地图按钮的UItableView。最后,当我切换地图按钮时,它将显示地图视图。 我的问题是,当在列表视图中时,我向下滚动,然后切换“地图视图”按钮,地图视图不会填满整个屏幕(请参见图片以供参考): 以下是我目前掌握的情况: 以下是我启动地图的方式: - (void)viewDidLoad { jobsMapView = [[MTJobsMap

我不熟悉在iOS中使用MapView,以下是我的情况: 当我切换附近的按钮时,它会将我重定向到地图视图:

然后,当我切换列表视图按钮时,它将显示一个带有地图按钮的UItableView。最后,当我切换地图按钮时,它将显示地图视图。 我的问题是,当在列表视图中时,我向下滚动,然后切换“地图视图”按钮,地图视图不会填满整个屏幕(请参见图片以供参考):

以下是我目前掌握的情况: 以下是我启动地图的方式:

- (void)viewDidLoad {
jobsMapView = [[MTJobsMapView alloc] initWithFrame:CGRectMake(0.0, 0.0,    self.view.frame.size.width, self.view.frame.size.height)];
jobsMapView.showsUserLocation = YES;
jobsMapView.zoomEnabled = YES;
jobsMapView.rotateEnabled = NO;
jobsMapView.parentViewController = self;
jobsMapView.delegate = jobsMapView;

// Set up buttons but hide them
showListViewButton = [UIButton buttonWithType:UIButtonTypeCustom];
showListViewButton.frame = CGRectMake(self.view.frame.size.width-58, self.view.frame.size.height-159, 50.0, 36.0);
[showListViewButton addTarget:self action:@selector(toggleNearbyView:) forControlEvents:UIControlEventTouchUpInside];
[showListViewButton setImage:[UIImage imageNamed:@"list.png"] forState:UIControlStateNormal];
[self.view addSubview:showListViewButton];

showMapViewButton = [UIButton buttonWithType:UIButtonTypeCustom];
showMapViewButton.frame = CGRectMake(self.view.frame.size.width-58, self.view.frame.size.height-159, 50.0, 36.0);
[showMapViewButton addTarget:self action:@selector(toggleNearbyView:) forControlEvents:UIControlEventTouchUpInside];
[showMapViewButton setImage:[UIImage imageNamed:@"icon_map.png"] forState:UIControlStateNormal];
[self.view addSubview:showMapViewButton];

// Default mapView is shown in Nearby View
showListViewButton.hidden = YES;
showListViewButton.enabled = NO;
showMapViewButton.hidden = YES;
showMapViewButton.enabled = NO;
self.listViewSelected = NO;
}

- (IBAction)toggleNearbyView:(UIButton *)sender {
self.listViewSelected = !self.listViewSelected;

if (self.listViewSelected) {

    self.title=[NSString stringWithFormat:@"Nearby Jobs (%d)",[[self.jobsDictionary objectForKey:@"sub_slots"] count]];
    // TableView is shown, so showMapViewButton for user to select MapView
    showMapViewButton.hidden = NO;
    showMapViewButton.enabled = YES;
    showListViewButton.hidden = YES;
    showListViewButton.enabled = NO;
    [jobsMapView removeFromSuperview];

} else {
    showListViewButton.hidden = NO;
    showListViewButton.enabled = YES;
    showMapViewButton.hidden = YES;
    showMapViewButton.enabled = NO;
    self.title=[NSString stringWithFormat:@"Nearby Jobs (%d)",[[self.FilterDictionary objectForKey:@"sub_slots"] count]];
    [jobsMapView mapViewWithJobsDisplayed:self.FilterDictionary andUserLocation:xapp.self.userLocation andUserCoordinates:xapp.self.userLocationCoordinates];
    [self.jobsTableView addSubview:jobsMapView];
}
}
我做错了什么? 任何帮助都将不胜感激。。 谢谢…

评论这一行

self.listViewSelected=!self.listViewSelected


在toggleNearbyView方法中

如果我对该行进行注释,当我切换列表视图按钮时,它会在您第一次添加tableview和map view时继续显示地图视图。因此,您必须删除mapview[jobsMapView removeFromsuperview]。