私はこのコードでカメラのビューを表示するiPhoneアプリケーションを開発しています:
-(void) displayAR {
[rootViewController presentModalViewController:[self cameraController] animated:NO];
[displayView setFrame:[[[self cameraController] view] bounds]];
}
そして、このコードでカメラのビューを非表示にします。
- (void) hideAR {
[[self locationManager] stopUpdatingHeading];
[[self locationManager] stopUpdatingLocation];
[[self accelerometerManager] release];
[rootViewController dismissModalViewControllerAnimated:YES];
}
hiddenARを呼び出すと、次のデバッガーのスクリーンショットでEXC_BAD_ACCESSが取得されます。
代替テキストhttp://img408.imageshack.us/img408/4550/capturadepantalla201006u.png
何かアドバイス?
アップデート:
これでhideARコードを変更しましたが、同じエラーが発生します。
- (void) hideAR {
[rootViewController dismissModalViewControllerAnimated:YES];
}
rootViewControllerを確認しましたが、nilではありません。
デバッガーのスクリーンショットでわかるように、最後に呼び出されたメソッド(スタックの最初のメソッド)は次のとおり[UIWindowController transitionViewDidComplete:fromView:toView]
です。
たぶん、それが却下された後、カメラのビューにアクセスする何かがあります。
2回目の更新
これらのメソッドを含むクラスは次のとおりです。
@implementation AugmentedRealityController
@synthesize locationManager;
@synthesize accelerometerManager;
@synthesize displayView;
@synthesize centerCoordinate;
@synthesize scaleViewsBasedOnDistance;
@synthesize rotateViewsBasedOnPerspective;
@synthesize maximumScaleDistance;
@synthesize minimumScaleFactor;
@synthesize maximumRotationAngle;
@synthesize centerLocation;
@synthesize coordinates = coordinates;
@synthesize debugMode;
@synthesize currentOrientation;
@synthesize degreeRange;
@synthesize rootViewController;
@synthesize cameraController;
- (id)initWithViewController:(UIViewController *)vc {
coordinates = [[NSMutableArray alloc] init];
coordinateViews = [[NSMutableArray alloc] init];
latestHeading = -1.0f;
debugView = nil;
[self setRootViewController: vc];
[self setDebugMode:NO];
[self setMaximumScaleDistance: 0.0];
[self setMinimumScaleFactor: 1.0];
[self setScaleViewsBasedOnDistance: NO];
[self setRotateViewsBasedOnPerspective: NO];
[self setMaximumRotationAngle: M_PI / 6.0];
CGRect screenRect = [[UIScreen mainScreen] bounds];
[self setDisplayView: [[UIView alloc] initWithFrame: screenRect]];
[self setCurrentOrientation:UIDeviceOrientationPortrait];
[self setDegreeRange:[[self displayView] bounds].size.width / 12];
[vc setView:displayView];
[self setCameraController: [[[UIImagePickerController alloc] init] autorelease]];
[[self cameraController] setSourceType: UIImagePickerControllerSourceTypeCamera];
[[self cameraController] setCameraViewTransform: CGAffineTransformScale([[self cameraController] cameraViewTransform], 1.13f, 1.13f)];
[[self cameraController] setShowsCameraControls:NO];
[[self cameraController] setNavigationBarHidden:YES];
[[self cameraController] setCameraOverlayView:displayView];
CLLocation *newCenter = [[CLLocation alloc] initWithLatitude:37.41711 longitude:-122.02528];
[self setCenterLocation: newCenter];
[newCenter release];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(deviceOrientationDidChange:)
name: UIDeviceOrientationDidChangeNotification
object:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
// Inicializa el gestor del GPS y el del acelerómetro.
[self startListening];
return self;
}
3番目の更新
NSLogトレースをいくつか入れましたが、hideAR呼び出しの後にdisplayARが呼び出されていることがわかります。また、viewDidAppear
メソッドonrootViewController
もhideARの後に呼び出されていることがわかります。実は、viewDidAppear
と呼んでdisplayAR
います。
なぜviewDidAppearと呼ばれるのですか?
4番目の更新
失敗している回線を見つけました。これは上の最初の行displayAR
です:
[rootViewController presentModalViewController:[self cameraController] animated:NO];
何か案は? rootViewController
そしてcameraController
、ゼロではありません。
FITH UPDATE
私のエラーを再現したい場合:
私はnielswhのiPhone-AR-Toolkitを使用しています(ここからダウンロードできます)。
ARKitDemoの例を変更してライブラリに含め、dismissModalViewを試すことができます。