【发布时间】:2010-11-24 20:04:28
【问题描述】:
是否可以使用 MKMapview 和另一个子视图创建视图。特别是我有一个地图视图,我一直在尝试添加第二个子视图(到超级视图,而不是 MKMapView。)问题是,虽然可以看到两个视图对 UIView 的任何触摸,但不是 MKMapView 传递到地图。我什至尝试移动地图以使它们不重叠,但另一个 UIView 相对于地图而不是窗口定位自身。
另一个令人好奇的是,代码在模拟器上运行良好,但在运行 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];
感谢您的建议。
【问题讨论】:
标签: iphone uiview mkmapview subview