我在将 a 集成ViewController
到另一个时遇到了一个奇怪的问题ViewController
。我会解释我的问题,
我有一个ParentViewController
(包含Buttons
(Ville/Autour De Moi,Carte/Liste ...)的那个,然后我在两个:和一个(包含地图的那个)ParentViewController
之间切换,我已经指定了框架采取:_ChildViewControllers
ListViewController
MapViewController
ChildViewControllers
( 0, 104, 320, 282)
if(mapViewController ==nil) {
mapViewController = [[MapViewController alloc] init];
mapViewController.networkViewController = self;
}
mapViewController.view.frame = CGRectMake( 0, 104, 320, 282);
[self.view addSubview:mapViewController.view];
一切都像魅力一样工作,但我遇到的问题是当我拖动地图时,我的标记和我的注释变成了上方ParentViewController
,并且它们隐藏了buttons
。
图片将解释我的问题:
拖动前:
在地图上拖动后:
注意:我ParentController
没有透明背景,地图也没有,我使用的是Mappy SDK IOS
添加注释的代码:MPPoiDataSourceMappyCustom.m
#import "MPPoiDataSourceMappyCustom.h"
@implementation MPPoiDataSourceMappyCustom
-(UIView *) labelAtIndex:(NSIndexPath *)indexPath withScreeLocation:(CGPoint)screenLocation withViewBounds:(CGRect)_bounds update:(BOOL)aUpdate {
// the label is allways up to date, we will not refresh it
if (aUpdate)
return nil;
if ([elementList count] > indexPath.row)
{
MPPoi * mpoi = [elementList objectAtIndex:indexPath.row];
MPGlobalStyle* style = [MPGlobalStyle sharedStyle];
style.textColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
//style.borderColor = [UIColor whiteColor];
style.textFont = [UIFont fontWithName:@"Helvetica-Bold" size:12.0];
style.borderColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
//style.borderColor = [UIColor colorWithRed:0.32 green:0.87 blue:0.05 alpha:1.0];
style.backgroundColor = [UIColor colorWithRed:0.627 green:0.066 blue:0.196 alpha:1.0];
MPCalloutView* mpCallOutView = [MPCalloutView calloutWithText:mpoi.uId withScreeLocation:screenLocation withViewBoundsWidth:_bounds.size.width];
// MPCalloutViewStyle* style = [MPCalloutViewStyle blackAndWhiteStyle];
mpCallOutView.popinstyle = style;
return mpCallOutView;
}
return nil;
}
@end
这是我用来显示标记的方法:
-(void) addMarkersOnMap {
MPMarkerManager * markerManager = [self.mapView markerManager];
MPMarkerCategory * category = [markerManager getCategory:STORE_LOC_CATEGORY];
//change the image of markers of this category
category.markerImage = [UIImage imageNamed:@"green-marker.png"];
//category settings
[category setOptimalZoom:YES];//set the zoom to be optimal : show all poi in the category
[category setHideLabelOnTheFirstShow:YES];
[category setAnimateAtFirstShow:YES];
//remove old elements
[category.dataSource removeAllElements];
//create new mappy data source for our cotegory ( stores)
MPPoiDataSourceMappyCustom* datasource = [[MPPoiDataSourceMappyCustom alloc] init ];
//add markers on map
for(int i=0; i<self.arrayStores.count; i++) {
NSDictionary* currentStore = [self.arrayStores objectAtIndex:i];
float latitude = [[currentStore objectForKey:@"latitude"] floatValue];
float longitude = [[currentStore objectForKey:@"longitude"] floatValue];
CLLocationCoordinate2D locationStore = CLLocationCoordinate2DMake(latitude, longitude);
//add the marker on the map for the current store
//create a new POI object with location
NSString* str = [NSString stringWithFormat:@"%@ \n %@ %d", [currentStore objectForKey:@"title"],[currentStore objectForKey:@"address"], [currentStore objectForKey:@"CP"] ];
MPPoi * poi = [[MPPoi alloc] initWithUId:str withLocation:locationStore];
[datasource addElement:poi];
[poi release];
NSLog(@"add store %d on the map , coordonnées :( %f , %f )", i,latitude,longitude);
}
[category setDataSource:datasource];
[datasource release];
//send all subviews to the back
for( UIView* view in [self.view subviews]) {
[self.view sendSubviewToBack:view];
}
}
关于这个奇怪问题的根源的任何想法朋友?这是来自 Mappy SDK 吗?我试图在 MapViewController 的子视图上进行 boocle 并将它们发送到 Back 但它对我不起作用。提前致谢