【问题标题】:didUpdateHeading not being called when view is used as cameraoverlay当视图用作cameraoverlay时没有调用didUpdateHeading
【发布时间】: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


    【解决方案1】:

    您是否保留了“LayoutViewController”对象?还是您仅将其视图设置为cameraOverlayView?

    如果你不保留它,CLLocationManager 也会被释放。

    【讨论】:

    • 好吧,我没有保留它,我只是写: LayoutViewController* overlayView = [self.storyboard instantiateViewControllerWithIdentifier:@"LayoutViewController"];选择器.cameraOverlayView=overlayView.view;你能告诉我正确保留它的方法吗?谢谢!
    • 您可以例如创建一个强属性来保留它:@property(strong,nonatomic) LayoutViewController* myRetainedController
    猜你喜欢
    • 1970-01-01
    • 2011-07-12
    • 1970-01-01
    • 1970-01-01
    • 2017-12-23
    • 1970-01-01
    • 1970-01-01
    • 2019-10-20
    • 2013-08-18
    相关资源
    最近更新 更多