Perform a task (in iOS) after animation has finished

后端 未结 4 714
离开以前
离开以前 2021-02-04 07:11

So I have this line of code:

[tableView setContentOffset:point animated:YES];

and I want to run another piece of code after the animation ends. My a

4条回答
  •  深忆病人
    2021-02-04 07:57

    You can create animations and tell them directly to perform a block after they're done.

    Here's an alternative that may play nicer with the UITableView's animations.

    [UIView beginAnimations:nil context:sender];
    [UIView setDelegate:self];
    [UIView setDidStopSelector:@selector(scrollMethod:)];
    [tableView setContentOffset:point];
    [UIView commitAnimations];
    

    And make sure to implement your scrollMethod: with this signature:

    - (void)scrollMethod:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
    

    You can use the context to know which sender you have. Read the UIView docs for more on UIView animations.

提交回复
热议问题