1

내 iPhone 응용 프로그램에서 웹 서비스 호출시 활동 표시기가 표시됩니다. 내 문제는 내가 활동 표시기가 표시되는보기를 만질 수 있다는 것입니다. 내보기는 텍스트 필드와 버튼을 가지고 있으며, 텍스트 필드에 값을 입력 할 수 있으며 활동 표시기가 여전히있는 동안 버튼 상태를 변경할 수 있습니다. . 비슷한 상황에 직면 한 사람이 있습니까? 아무도이 문제에 대한 해결책을 알고 있습니까? 모든 유용한 제안을 환영합니다. 다음은 내 활동 표시기 클래스입니다.활동 표시기의 배경을 터치 할 수 있습니다.

ActivityProgressViewController.h

#import <UIKit/UIKit.h> 

@interface ActivityProgressViewController : UIViewController { 
    IBOutlet UIActivityIndicatorView *_activityIndicator; 
    IBOutlet UILabel *_labelMessage; 
    NSString *_messageToShow; 
} 

@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *activityIndicator; 
@property (nonatomic, retain) IBOutlet UILabel *labelMessage; 

+ (ActivityProgressViewController*) createInstance; 

- (void)show; 
- (void)showWithMessage:(NSString*)message; 
- (void)close; 


+ (void)show; 
+ (void)close; 

@end 

ActivityProgressViewController.m 여기

#import "ActivityProgressViewController.h" 

#define kACTIVITY_INDICATOR_NIB @"ActivityProgressViewController" 

@implementation ActivityProgressViewController 

@synthesize activityIndicator = _activityIndicator; 
@synthesize labelMessage = _labelMessage; 


static ActivityProgressViewController *_viewController; 


- (void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 
} 

- (void)viewDidLoad { 
    if (_messageToShow) _labelMessage.text = _messageToShow; 
} 

- (void)dealloc { 
    [_labelMessage release]; 
    [_messageToShow release]; 
    [_activityIndicator release]; 
    [super dealloc]; 
} 

+ (ActivityProgressViewController*) createInstance { 
    _viewController = [[ActivityProgressViewController alloc] initWithNibName:kACTIVITY_INDICATOR_NIB bundle:nil]; 
    return _viewController; 
} 

- (void)show 
{ 
    [_activityIndicator startAnimating]; 

    UIWindow *window = [[[UIApplication sharedApplication] windows]objectAtIndex:0]; 
    NSLog(@"[[UIApplication sharedApplication] windows]===%@",[[UIApplication sharedApplication] windows]); 

    self.view.frame = CGRectMake(window.bounds.origin.x, window.bounds.origin.y, window.bounds.size.width, window.bounds.size.height); 

    [window addSubview:self.view]; 

} 



- (void)showWithMessage:(NSString*)message { 
    _messageToShow = message; 
    [self show]; 
} 

- (void)close 
{ 
    [self.view removeFromSuperview]; 

} 

+ (void)show { 
    if (!_viewController) { 
     _viewController = [ActivityProgressViewController createInstance]; 
    } 
    [_viewController show]; 
} 

+ (void)close { 
    if (_viewController) { 
     [_viewController close]; 
    } 
} 

@end 

은 내가 어떻게 내 필요한 클래스에서 전화.

[ActivityProgressViewController show]; 

[ActivityProgressViewController close]; 

나는 또한 호출 활동 표시 오디오를 수출하고있다. 이 그래, 난 당신이 다른보기의 중간에 활동 표시를 추가하는

-(void)exportAudioFile:(AVComposition*)combinedComposition 
{ 

[ActivityProgressViewController show]; 

AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:combinedComposition 
                      presetName:AVAssetExportPresetPassthrough]; 

    NSArray *presets =[AVAssetExportSession exportPresetsCompatibleWithAsset:combinedComposition]; 

    NSLog(@"presets======%@",presets); 
    NSLog (@"can export: %@", exportSession.supportedFileTypes); 
    NSArray *dirs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectoryPath = [dirs objectAtIndex:0]; 
    exportPath = [documentsDirectoryPath stringByAppendingPathComponent:@"CombinedNew.m4a"]; 
    [[NSFileManager defaultManager] removeItemAtPath:exportPath error:nil]; 
    exportURL = [NSURL fileURLWithPath:exportPath]; 
    exportSession.outputURL = exportURL; 
    exportSession.outputFileType = @"com.apple.m4a-audio"; 
    exportSession.shouldOptimizeForNetworkUse = YES; 
    [exportSession exportAsynchronouslyWithCompletionHandler:^{ 
     NSLog (@"i is in your block, exportin. status is %d", 
       exportSession.status); 
     switch (exportSession.status) 
     { 
      case AVAssetExportSessionStatusFailed: 
      { 

       break; 
      } 
      case AVAssetExportSessionStatusCompleted: 
      { 

       exportSuccess = YES; 
       if (recorderFilePath) 
       { 
        NSError *finalurlError; 
        [[NSFileManager defaultManager]removeItemAtPath:recorderFilePath error:&finalurlError]; 
        finalurlError = nil; 
        [[NSFileManager defaultManager]copyItemAtPath:[exportURL path] toPath:recorderFilePath error:&finalurlError]; 
        NSLog(@"finalurlError 2-----%@",finalurlError); 
       } 
       [ActivityProgressViewController close]; 
       fileUrl = [NSURL fileURLWithPath:recorderFilePath]; 
       [self updatePlayerForUrl:fileUrl]; 
       break; 
      } 
      case AVAssetExportSessionStatusUnknown: 
      { 

       break; 
      } 
      case AVAssetExportSessionStatusExporting: 
      { 

       break; 
      } 
      case AVAssetExportSessionStatusCancelled: 
      { 

       break; 
      } 
      case AVAssetExportSessionStatusWaiting: 
      { 

       break; 
      } 
      default: 
      { 
       NSLog (@"didn't get export status"); 
       break; 
      } 

     }; 
    }]; 

    [exportSession release]; 
} 

답변

4

수출에 사용하는 코드는?

그렇다면, 당신은 당신의 show 방법으로이 작업을 수행 할 수 있습니다

self.superview.userInteractionEnabled = NO; 

그리고 당신의 close 방법 : 당신이있는 UIView의 userInteractionEnabled 특성에 대한 정보를 찾아 볼 수있는 곳

다음
self.superview.userInteractionEnabled = YES; 

이입니다 : http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/userInteractionEnabled

희망이 있습니다.

+0

작동했습니다. 감사합니다.하지만 여전히 문제가 있습니다. 내 애플리케이션에서 오디오 파일을 내보내는 동안 해당 활동 표시기도 사용합니다. 여기에서도 같은 문제가 발생합니다. – Siddharth

+0

동일한 해결책도 거기에서 작동해야합니다. 어떤 관점에서 액티비티 인디케이터를 추가했는지에 상관없이,'userInteractionEnabled'를 NO로 설정하면 액티비티가 끝날 때까지 쳐다 보지 않아야합니다. –

+0

수출중인 경우 [ActivityProgressViewController 닫기]가 호출 된 것으로 나타났습니다. 하지만 그 후에 활동 표시기가 여전히 존재하며 배경보기의 UI 요소를 만질 수 있습니다. 비동기 수출과 관련이 있다고 생각합니다. 참조 용으로 위의 내보내기 코드를 추가했습니다. – Siddharth