0

I'm getting a really long (about 6 seconds) delay between when I call transitionWithViewand when the animation actually starts on the screen. Is it because I am calling transitionWithView from a handler or something?

- (IBAction)saveToCal:(id)sender{
    LBWrapperView *wrapper = (LBWrapperView*)self.parentViewController;
    EKEventStore *store = [EKEventStore new];
    [store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        if (!granted) { return; }
        EKEvent *event = [EKEvent eventWithEventStore:store];
        event.title = wrapper.lunch.title;
        ...
        event.calendar = [store defaultCalendarForNewEvents];
        NSError *err = nil;
        [store saveEvent:event span:EKSpanThisEvent commit:YES error:&err];
        if (!err){
            [UIView transitionWithView:self.addToCalendarBtn duration:1.0 options:UIViewAnimationOptionCurveLinear animations:^{
                self.addToCalendarBtn.alpha = 0.0;
            } completion:nil];

        }
    }];
}

Edit: I also have the same problem when calling:

[UIView animateWithDuration:1.0 animations:^{
    self.addToCalendarBtn.alpha = 0.0;
}];
Chase Roberts
  • 9,082
  • 13
  • 73
  • 131
  • I think you're response is here: http://stackoverflow.com/a/13886839/1514637 – Mehdi Hosseinzadeh Oct 03 '15 at 15:58
  • I think that's for two conflicting animations. I'm only doing one animation. I did try to change the `transitionWithView` view to self.addToCalendarBtn but it didn't change anything. I also tried to call `animateWithDuration` which didn't solve the problem either. – Chase Roberts Oct 03 '15 at 16:20

1 Answers1

1

Are you sure you're running under main thread? Using other threads also make User interface manipulation laggy.

You can use below code to changing you're UI manipulation to main thread:

dispatch_async(dispatch_get_main_queue(), ^{
    [UIView transitionWithView:self.addToCalendarBtn duration:1.0 options:UIViewAnimationOptionCurveLinear animations:^{
            self.addToCalendarBtn.alpha = 0.0;
     } completion:nil];
});
Mehdi Hosseinzadeh
  • 1,160
  • 11
  • 25