2010-11-24 58 views
1

是否可以使用MKMapview和其他子视图创建视图。特别是我有一个地图视图,我一直试图添加第二个子视图(到superview,而不是MKMapView)。问题是,虽然这两个视图可以看到任何接触不是MKMapView的UIView传递给地图。我甚至试图移动地图,使它们不重叠,但另一个UIView相对于地图而不是窗口定位。使用MKMapView和可触摸的子视图创建视图

另外一个好奇的是代码在模拟器上正常工作,但不在运行3.1.3的测试设备上。这可能是3.1.3版MKMapView的问题,或者只是模拟器中的一个怪癖?

我的代码是

combinedView = [[UIView alloc] initWithFrame:self.view.frame]; 

self.awView = [[AdWhirlView alloc] init]; 
awView = [AdWhirlView requestAdWhirlViewWithDelegate:self]; 
self.awView.delegate = self; 

[combinedView addSubview:awView]; 

mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0,50,320,430)]; 
mapView = (MKMapView*)self.view; 
mapView.delegate = self; 
//[self.view insertSubview:mapView atIndex:0]; 

[combinedView addSubview:mapView]; 

//mapView.showsUserLocation = YES; 
// Create a location coordinate object 
CLLocationCoordinate2D coordinate; 

coordinate.latitude = 40.1; 
coordinate.longitude = -76.30575; 

// Display map 
mapView.region = MKCoordinateRegionMakeWithDistance(coordinate, 40000, 40000); 

[combinedView bringSubviewToFront:awView]; 

感谢您的任何意见。

回答

0

不太熟悉AdWhirlView,但它可能需要为此设置一个框架吗? CGRectMake(0,0,320,50);什么的?

否则,你可能想玩两个视图的autoresizeMasks。我知道肯定你可以有一个MKMapView与兄弟的意见,他们都工作正常。

+0

感谢您的建议。我在alloc后添加了一个setFrame(\t [awView setFrame:CGRectMake(0.0,0.0,320.0,50.0)];)但触摸仍然没有被捕获,但通过。我知道iAd可以在MKMapView上运行,这就是为什么我想知道它是否是OS 3的问题。 – LancDec 2010-11-24 20:22:13