Closed Tippit closed 9 years ago
how about setup
?
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; }
(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];
[self setEffectMenu];
_menuScroll.transform = CGAffineTransformMakeTranslation(0, self.editor.view.height-_menuScroll.top); [UIView animateWithDuration:kCLImageToolAnimationDuration animations:^{ _menuScroll.transform = CGAffineTransformIdentity; }]; [_indicatorView stopAnimating]; }
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];
});
}
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!
oups! i use iOS9 Xcode 7 beta 4
where do you initialize the _indicatorView? if you don't initialize it, you should do it in setup.
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
_indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
_indicatorView.center = CGPointMake(160, 240);
_indicatorView.hidesWhenStopped = YES;
[self.editor.imageView addSubview:_indicatorView];
Still does not work
It's OK Yackle the indicator was hidden by the image and not well centered, sorry for the inconvenience. You are awesome!
:+1:
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