【发布时间】:2015-02-25 18:11:51
【问题描述】:
我对以下代码有疑问:
我已经实现了一个名为LayoutViewController 的简单ViewController,它显示了一个根据磁航向自动移动的图片。代码包括:
lm = [[CLLocationManager alloc] init];
lm.delegate = self;
lm.desiredAccuracy = kCLLocationAccuracyBest;
lm.distanceFilter = kCLDistanceFilterNone;
[lm startUpdatingLocation];
lm.headingFilter = kCLHeadingFilterNone;
[lm startUpdatingHeading];
在视图中确实加载了,然后我实现了 didUpdateHeading,在此执行动画。一切正常。在另一个视图控制器中,我放置了一个按钮,并在 IBAction 中放置了:
LayoutViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"LayoutViewController"];
一切正常。
问题是,如果我尝试使用 LayoutViewController 作为相机覆盖视图,动画不起作用。
我实现了:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = YES;
picker.modalPresentationStyle = UIModalPresentationFullScreen;
LayoutViewController* overlayView = [self.storyboard instantiateViewControllerWithIdentifier:@"LayoutViewController"];
picker.cameraOverlayView=overlayView.view;
([picker setCameraOverlayView:overlayView.view] 而不是picker.cameraOverlayView=overlayView.view 给出了同样的问题)
这样做时,它会打开相机,我可以在 LayoutViewController 中看到我的图片,因此 LayoutViewController 实例已成功加载,但没有执行动画,因为它接缝 didupdateheading 没有被调用。
请帮帮我!
【问题讨论】:
标签: ios objective-c xcode cameraoverlayview