开发者

setAnimationDidStopSelector @selector not running method

I have used this previously in my app, and having looked over everything I cannot find the difference, but for some reason when I run:

-(void)moveSelectorToDisplayPosition:(id)sender{

    int givenTag = [sender tag];
    UIImageView *tempImageView = [displayedSelections objectAtIndex:givenTag];



    [UIView beginAnimations:@"" context:NULL];
    [UIView setAnimationDuration:.3];
    tempImageView.frame = CGRectOffset(tempImageView.frame, 30 - tempImageView.frame.or开发者_StackOverflow社区igin.x,  240 - tempImageView.frame.origin.y);
    [UIView setAnimationDidStopSelector:@selector(loadInTextForSelectedTool:)];
    [UIView commitAnimations]; 
}

loadInTextForSelectedTool does not get called and I cannot figure out why. No errors or anything.

This is the method I'm trying to run, could anyone let me know if they see anything amiss or maybe something I might have forgotten? I tried also setting the [UIView setAnimationDelegate:tempImageView]; but no luck :(.

-(void)loadInTextForSelectedTool:(id)sender;

Thanks.


You need to set the delegate to the controller that implements loadInTextForSelectedTool:

[UIView setAnimationDelegate:self];

Also, according to the documentation, the selector should have the following form:

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

And finally, Apple discourages the use of this animation method in iOS 4.0 or later:

Use of this method is discouraged in iOS 4.0 and later. You should use the block-based animation methods to specify your animations instead.


Unless you need to run on 3.2 or earlier, you should be using block animations. They really simplify specifying what to do at the end of an animation.

http://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingViews/AnimatingViews.html#//apple_ref/doc/uid/TP40009503-CH6-SW1

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜