Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 当视图用作cameraoverlay时,未调用didUpdateHeading_Ios_Objective C_Xcode_Cameraoverlayview - Fatal编程技术网

Ios 当视图用作cameraoverlay时,未调用didUpdateHeading

Ios 当视图用作cameraoverlay时,未调用didUpdateHeading,ios,objective-c,xcode,cameraoverlayview,Ios,Objective C,Xcode,Cameraoverlayview,我对以下代码有问题: 我已经实现了一个名为LayoutViewController的简单ViewController,它显示一个根据磁航向自动移动的图片。该守则包括: lm = [[CLLocationManager alloc] init]; lm.delegate = self; lm.desiredAccuracy = kCLLocationAccuracyBest; lm.distanceFilter = kCLDistanceFilterNone; [lm startUpdatingL

我对以下代码有问题:

我已经实现了一个名为LayoutViewController的简单ViewController,它显示一个根据磁航向自动移动的图片。该守则包括:

lm = [[CLLocationManager alloc] init];
lm.delegate = self;
lm.desiredAccuracy = kCLLocationAccuracyBest;
lm.distanceFilter = kCLDistanceFilterNone;
[lm startUpdatingLocation];
lm.headingFilter = kCLHeadingFilterNone;
[lm startUpdatingHeading];
在view Dod load中,我实现了didUpdateHeading,在那里执行动画。一切正常。在另一个视图控制器中,我放置了一个按钮,并在iAction中放置:

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实例已成功加载,但不会执行任何动画,因为它没有调用UpdateHeading


请帮帮我

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


如果您不保留它,CLLocationManager也将被解除分配。

我没有保留它,我只是写:LayoutViewController*overlayView=[self.storyboard InstanceiveViewController标识符:@LayoutViewController];picker.cameraOverlayView=overlayView.view;你能告诉我如何妥善保管它吗?非常感谢。例如,您可以创建一个强属性来保留它:@propertystrong,非原子LayoutViewController*myRetainedController