【发布时间】:2015-01-18 18:46:32
【问题描述】:
我创建了一个测试项目,它有一个 UIViewController。一个 UIView (myView) 声明为 xib 它有一个图像和 3 个按钮
我以编程方式将 UIView 添加到 UIViewController 并在 UIViewController 的 viewDidLoad 方法中向 UIView 添加滑动手势
swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeAction:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[myView addGestureRecognizer:swipeRight];
[self.view addSubview:myView];
一切正常。
然后我在viewDidLoad中再次将谷歌地图添加到UIViewcontroller
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;
第一个问题: myview 没有显示 --> 我把添加 UIView 的代码移到viewDidAppear.
现在可以看到视图按钮响应但滑动手势不起作用
有什么想法吗?
【问题讨论】:
标签: ios objective-c google-maps uiview