2015-06-24 52 views
1

在用戶批准了相機和GPS的權限之後,我有黑屏與pois。它像是有一個問題實現了相機,因爲pois正在移動設備的位置改變,以便部分工作很好,另外如果我殺了應用程序,然後啓動它everyting很好(用戶已經批准權限)任何想法什麼可能是問題?代碼如下:iOS上的Wikitude黑屏8.3

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    NSError *deviceNotSupportedError = nil; 
    if ([WTArchitectView isDeviceSupportedForRequiredFeatures:WTFeature_Geo error:&deviceNotSupportedError]) { // 1 
     self.architectView.delegate = self; 
     [self.architectView setLicenseKey:@""]; 

     self.architectWorldNavigation = [self.architectView loadArchitectWorldFromURL:[[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html" subdirectory:@"4_PointOfInterest_4_SelectingPois"] withRequiredFeatures:WTFeature_Geo | WTFeature_2DTracking]; 

     [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification 
                  object:nil 
                  queue:[NSOperationQueue mainQueue] 
                 usingBlock:^(NSNotification *note) { 
                  if (self.architectWorldNavigation.wasInterrupted) { 
                   [self.architectView reloadArchitectWorld]; 
                  } 
                  [self startRunning]; 
                 }]; 

     [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification 
                  object:nil 
                  queue:[NSOperationQueue mainQueue] 
                 usingBlock:^(NSNotification *note) { 
                  [self startRunning]; 
                 }]; 

    } else { 
     NSLog(@"device is not supported - reason: %@", [deviceNotSupportedError localizedDescription]); 
    } 
} 

-(void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    [self startRunning]; 
} 

- (void)startRunning { 

    if (![self.architectView isRunning]) { 
     [self.architectView start:^(WTStartupConfiguration *configuration) { 
      configuration.captureDevicePosition= AVCaptureDevicePositionBack; 

     } completion:^(BOOL isRunning, NSError *error) { 
      if (!isRunning) { 
       NSLog(@"WTArchitectView could not be started. Reason: %@", [error localizedDescription]); 
      } 
     }]; 
    } 
} 

回答

0

我通過檢查UIApplicationDidBecomeActiveNotification通知來解決此問題,如果Wikitude引擎處於打開狀態。如果沒有,我執行Wikitude的開始方法,一切正常。

- (void)startRunning { 
    self.observers = [[NSMutableArray alloc] init]; 
    NSError *deviceNotSupportedError = nil; 
    if ([WTArchitectView isDeviceSupportedForRequiredFeatures:WTFeature_Geo error:&deviceNotSupportedError]) { 
     self.architectView.delegate = self; 
     self.architectView.desiredLocationAccuracy = kCLLocationAccuracyNearestTenMeters; 
     [self.architectView setLicenseKey:kWikiTudeLicenseKey]; 

     NSURL *architectWorldUrl = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html" subdirectory:kWikitudeHTMLFileSubDictionary]; 
     self.architectWorldNavigation = [self.architectView loadArchitectWorldFromURL:architectWorldUrl withRequiredFeatures:WTFeature_Geo]; 

     for (id object in self.observers) { 
      [[NSNotificationCenter defaultCenter] removeObserver:object]; 
     } 

     id observer = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification 
                     object:nil 
                     queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { 

                      if (self.architectWorldNavigation.wasInterrupted) { 
                       [self.architectView reloadArchitectWorld]; 
                      } 
                      [self startServiceIfNeeded]; 
                     }]; 
     id observer1 = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification 
                     object:nil 
                      queue:[NSOperationQueue mainQueue] 
                    usingBlock:^(NSNotification *note) { 
                     if ([self.architectView isRunning]) 
                     { 
                      [self.architectView stop]; 
                     } 
                    }]; 
     [self.observers addObject:observer]; 
     [self.observers addObject:observer1]; 
    } else { 
     DLog(@"device is not supported - reason: %@", [deviceNotSupportedError localizedDescription]); 
    } 

    if (![self.architectView isRunning]) { 
     [self.architectView start:^(WTStartupConfiguration *configuration) { 
      configuration.captureDevicePosition = AVCaptureDevicePositionBack; 
     } completion:^(BOOL isRunning, NSError *error) { 
      if (!isRunning) { 
       NSLog(@"WTArchitectView could not be started. Reason: %@", [error localizedDescription]); 
      } 
      self.didStart = isRunning; 
      if (self.didStartedEngine) { 
       self.didStartedEngine(); 
      } 

     }]; 
    } 
} 

    - (void)startServiceIfNeeded { 
     if (![self.architectView isRunning]) { 
      [self.architectView start:^(WTStartupConfiguration *configuration) { 
       configuration.captureDevicePosition = AVCaptureDevicePositionBack; 
      } completion:^(BOOL isRunning, NSError *error) { 
       if (!isRunning) { 
        NSLog(@"WTArchitectView could not be started. Reason: %@", [error localizedDescription]); 
       } 
      }]; 
     } 
    } 
0

將其他鏈接器標誌設置爲-ObjC用於Debug和Release on Build Settings。 enter image description here