我在將ViewController
集成到另一個ViewController
中時出現了一個奇怪的問題。 我會解釋我的問題,將childViewController添加到ParentViewController中的問題
我有誰包含ParentViewController
(一Buttons
(威樂/ Autour德莫伊,點菜/清單當然 ...),並進入該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
。
圖像將解釋我的問題:
拖動前:
NB:我ParentController
沒有按
在地圖上拖動後沒有透明背景,t他也映射,和我使用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的子視圖上拼湊起來,並將它們發送給Back,但它對我不起作用。 由於事先
任何幫助?? ...? – Houcine