次のコードに問題があります。
LayoutViewControllerという名前の単純な ViewController を実装しました。このViewControllerは、磁方位に従って自動的に移動する画像を表示します。コードは以下で構成されています。
lm = [[CLLocationManager alloc] init];
lm.delegate = self;
lm.desiredAccuracy = kCLLocationAccuracyBest;
lm.distanceFilter = kCLDistanceFilterNone;
[lm startUpdatingLocation];
lm.headingFilter = kCLHeadingFilterNone;
[lm startUpdatingHeading];
ビューでロードした後、アニメーションが実行される didUpdateHeading を実装しました。すべて正常に動作します。別のView Controllerにボタンを配置し、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 が呼び出されていないため、アニメーションは実行されません。
私を助けてください!