yackle / CLImageEditor

MIT License
2.22k stars 574 forks source link

Long Process to load ToolBar #111

Closed Tippit closed 9 years ago

Tippit commented 9 years ago

I have tool derived from Effect Tool wich load more than 200 images in toolbar so i want to put an UIActivityIndicatorView what is the best place in code to do that? please

yackle commented 9 years ago

how about setup?

Tippit commented 9 years ago

It was my first idea but i can't do it work, this is my code :(

@interface CLEffectTool() @property (nonatomic, strong) UIView selectedMenu; @property (nonatomic, strong) CLEffectBase selectedEffect; @property (nonatomic, strong) UIActivityIndicatorView *indicatorView; @end

@implementation CLEffectTool { UIImage _originalImage; UIImage _thumbnailImage; UIScrollView _menuScroll; UIActivityIndicatorView _indicatorView; }

yackle commented 9 years ago

the simplest way is to use dispatch_after (dispatch_async will be also able to use). for example

- (void)setup
{
    [_indicatorView startAnimating];
    _originalImage = self.editor.imageView.image;
    _thumbnailImage = [_originalImage resize:self.editor.imageView.frame.size];

    [self.editor fixZoomScaleWithAnimated:YES];

    _menuScroll = [[UIScrollView alloc] initWithFrame:self.editor.menuView.frame];
    _menuScroll.backgroundColor = self.editor.menuView.backgroundColor;
    _menuScroll.showsHorizontalScrollIndicator = NO;
    _menuScroll.layer.masksToBounds=YES;
    [self.editor.view addSubview:_menuScroll];

    _menuScroll.transform = CGAffineTransformMakeTranslation(0, self.editor.view.height-_menuScroll.top);

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self setEffectMenu];

        [UIView animateWithDuration:kCLImageToolAnimationDuration
                         animations:^{
                             _menuScroll.transform = CGAffineTransformIdentity;
                         }];
        [_indicatorView stopAnimating];
    });

}
Tippit commented 9 years ago

I tried. when i tape on Effects tool on toolbar it disappears (ToolBar) and becomes white until the process ending, the toolbar appears but the _indicatorView never shown!

Tippit commented 9 years ago

oups! i use iOS9 Xcode 7 beta 4

yackle commented 9 years ago

where do you initialize the _indicatorView? if you don't initialize it, you should do it in setup.

Tippit commented 9 years ago

I had this

UIActivityIndicatorView *indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indicatorView.center = CGPointMake(160, 240);
indicatorView.hidesWhenStopped = YES;
[self.editor.imageView addSubview:_indicatorView];

but still doesn't work

yackle commented 9 years ago
_indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
_indicatorView.center = CGPointMake(160, 240);
_indicatorView.hidesWhenStopped = YES;
[self.editor.imageView addSubview:_indicatorView];
Tippit commented 9 years ago

Still does not work

Tippit commented 9 years ago

It's OK Yackle the indicator was hidden by the image and not well centered, sorry for the inconvenience. You are awesome!

yackle commented 9 years ago

:+1: