2013-12-19 2 views
0

카메라 버튼을 사용하여 사진을 찍을 수있는 테스트 앱을 만들었습니다. 시뮬레이터에서 테스트 중이므로 스냅 샷을 만들 수 없습니다. 하지만 호출 될 때 사용자가 사진 라이브러리에서 사진을 선택할 수있는 IBAction 메서드를 만들었습니다. 위의 시나리오에서NSLog가 실행되지 않음

- (IBAction)takePicture:(id)sender { 
      NSLog(@"Camera button tapped"); 
      UIImagePickerController *imagePicker= [[UIImagePickerController alloc] init]; 
       if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 
        NSLog(@"Yes. The Camera is available"); 
        [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera]; 

       } 
       else{ 
       NSLog(@"The Camera isn't available. Try thru the Photo Library"); 
       [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; 
       } 
      imagePicker.allowsEditing=YES; 
      [imagePicker setDelegate:self]; 

      NSLog(@"Presenting Modal Controller"); 
      [self presentViewController:imagePicker animated:YES completion:NULL]; 

     } 

, 메소드가 콘솔뿐만 아니라 카메라 버튼을 탭 메시지를 기록하지 않습니다 (내가 카메라 모음 단추 항목을 누를 때 즉)이라고합니다 - : 이는 방법 모달 컨트롤러 제시 메시지. 다른 모든 적절한 NSLog 메시지는 그대로 기록됩니다. 런타임에서이 NSLog 행을 어떻게 실행하지 않는지 이해할 수 없습니다. 비슷한 문제가 있습니다 - (void) imagePickerController : (UIImagePickerController *) picker didFinishPickingMediaWithInfo : (NSDictionary *) info 내가 직면하고 있습니다. 구현 방법은 다음과 같습니다.

 -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ 
      NSLog(@"imagePicker called"); 
      NSString *oldKey= _item.imageKey; 
      if (oldKey) { 
       NSLog(@"Deleting image having key- %@",oldKey); 
       [[BNRImageStore sharedStore] deleteImageForKey:oldKey]; 
      } 

      UIImage *image= [info objectForKey:UIImagePickerControllerEditedImage]; 

      CFUUIDRef newUniqueID= CFUUIDCreate(kCFAllocatorDefault); 
      CFStringRef newUniqueIDString= CFUUIDCreateString(kCFAllocatorDefault, newUniqueID); 

      //Use that uniqueID to set our item's imageKey 
      NSString *key= (__bridge NSString *)newUniqueIDString; 
      _item.imageKey=key; 

      //Store image in the BNRImageStore with this key 
      NSLog(@"putting %@ in dictionary table",_item.imageKey); 
      [[BNRImageStore sharedStore] setImage:image forKey:_item.imageKey]; 

      //Releasing Core-Foundation objects 
      CFRelease(newUniqueIDString); 
      CFRelease(newUniqueID); 

      [imageView setImage:image]; 
      NSLog(@"Dismissing Modal Controller"); 
      [self dismissViewControllerAnimated:YES completion:NULL]; 
    } 

여기에 있습니다. NSLog 메시지 imagePicker는이고 세 번째 마지막 줄에는 모달 컨트롤러 해제 중이 콘솔에 표시되지 않습니다. 다시 런타임은 이러한 NSLog 라인을 처리하지 않습니다.

나는이 동작이 매우 이상하다고 생각하기 때문에 잘못된 것이라고 가정합니다. 무슨 일이야?

+0

이것은 파생 된 데이터 문제와 같습니다. 파생 데이터 삭제 및 클린 빌드 수행 –

+0

파생 데이터 란 정확히 무엇입니까 ?? – rahulbsb

+0

특정 폴더의 내용을 삭제해도 안전합니까 ?? 그것은 무엇을 할 것인가? – rahulbsb

답변

0

확인하려면 다음 코드 줄 : - 그것이

#define NSLog if(0) NSLog 

경우 다음 nslog 문이 실행되지 않습니다 0을 언급. 그래서 일을하고

#define NSLog if(1) NSLog 
0
other than NSLog .. is your app functionality working fine? few statements like NSLog (in editoe), PO(Console), P(Console) will not work some time, some time these will show wrong values also. functionality is working fine then try to show alert instead of NSLog and check. 

가 대신 NSLog의 사용 시도하고 확인 확인.

#ifdef DEBUG 
#define ALog(s, ...) NSLog(@"\n\n************************ DEBUG ***********************\n Class&method: %@,\n Line of Code: %d\n element Info: %@\n******************************************************************\n\n", \ 

[있는 NSString stringWithUTF8String : FUNCTION] lastPathComponent] \ LINE [있는 NSString stringWithFormat (S), ## VA_ARGS]);

#DEFINE ALOG (...) 단지 NSLog의 예처럼 사용

#endif 다음 #else : ALOG ("로그가 배치"@);