Adding a UIActivityIndicator to a modal view (ELCimagepicker)

后端 未结 3 1250
挽巷
挽巷 2021-01-06 17:40

I\'ve added the ELCimagepicker (https://github.com/Fingertips/ELCImagePickerController) to my project and it works perfectly, allowing the user to select multiple images for

相关标签:
3条回答
  • 2021-01-06 18:20

    It looks like you are updating UI on a background thread. All UIKit updates are to be done in the main thread. So I recommend you execute methods doing UI updates using performSelectorOnMainThread:withObject:.

    0 讨论(0)
  • 2021-01-06 18:22

    I solved the issue like this

         activityIndicatorObject = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    
         // Set Center Position for ActivityIndicator
    
         activityIndicatorObject.center = CGPointMake(150, 250);
         activityIndicatorObject.backgroundColor=[UIColor grayColor];
    
         // Add ActivityIndicator to your view
         [self.view addSubview:activityIndicatorObject];
    
         activityIndicatorObject.hidesWhenStopped=NO;
    
         [activityIndicatorObject startAnimating];
    
    0 讨论(0)
  • 2021-01-06 18:39

    I have figure out your problem. You can do this as below..

    -(void)selectedAssets:(NSArray*)_assets {
    
    UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    UIViewController * topView = [self.viewControllers objectAtIndex:[self.viewControllers count]-1];
    activityIndicator.center = CGPointMake(topView.view.frame.size.width/2, topView.view.frame.size.height/2);
    [activityIndicator setHidden:NO];
    [topView.view addSubview:activityIndicator];
    [topView.view bringSubviewToFront:activityIndicator];
    [activityIndicator startAnimating];
    
    [self performSelector:@selector(doProcess:) withObject:_assets afterDelay:2.1];
    
    }
    
    - (void) doProcess:(NSArray *)_assets {
    
    NSMutableArray *returnArray = [[[NSMutableArray alloc] init] autorelease];
    
    for(ALAsset *asset in _assets) {
    
        NSMutableDictionary *workingDictionary = [[NSMutableDictionary alloc] init];
        [workingDictionary setObject:[asset valueForProperty:ALAssetPropertyType] forKey:@"UIImagePickerControllerMediaType"];
        [workingDictionary setObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]] forKey:@"UIImagePickerControllerOriginalImage"];
        [workingDictionary setObject:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]] forKey:@"UIImagePickerControllerReferenceURL"];
    
        [returnArray addObject:workingDictionary];
    
        [workingDictionary release];    
    }
    
    [self popToRootViewControllerAnimated:NO];
    [[self parentViewController] dismissModalViewControllerAnimated:YES];
    
    if([delegate respondsToSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:)]) {
        [delegate performSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:) withObject:self withObject:[NSArray arrayWithArray:returnArray]];
    }
    
    }
    

    Let me know if this answer help you ...

    Thanks, MinuMaster

    0 讨论(0)
提交回复
热议问题