Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple rejected app because of animationDidStop:finished:context: is a non-public api

Apple rejected my app because:

3.3.1 Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs. Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited).

The non-public API that is included in your application is animationDidStop:finished:context:.

This is my method in which I am using the call to above mentioned method:

- (void)hideMsg
{

// Slide the view off screen
CGRect frame = self.view.frame;
int retractY;
int retractX;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.75];

retractY = -190;
retractX = 0;

frame.origin.y = retractY;
frame.origin.x = retractX;
self.view.frame = frame;

//to autorelease the Msg, define stop selector
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

[UIView commitAnimations];

}

I'm using this method to display a sliding message after occurence of certain event.

But I have nowhere defined this method. When I tried to find it was only found in CAAnimation.h, UIView.h.

Has anybody encountered with the same problem? How did you fix it?

like image 287
neha Avatar asked Dec 23 '22 00:12

neha


2 Answers

The whole point of setAnimationDidStopSelector: is that you are telling the system to call your own custom method when an animation completes. So, if you are going to pass in that selector you need to define that method in your class yourself:

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
   // do whatever.
}

Note the documentation for setAnimationDidStopSelector: says you must use a selector of this form, but in reality you can also use a shorter one like mad-dog described. But, it's better to get the animationID and context and other items to examine.

You need to add the method to whatever class that code is in because you are passing self as the animation delegate.

They probably also have an internal UIView method of the same name for some reason, which is why you are being accused of using an undocumented API.

like image 117
Kendall Helmstetter Gelner Avatar answered Dec 24 '22 12:12

Kendall Helmstetter Gelner


If you need to perform some action (like releasing objects) when the animation has finished you should define your own method then pass a selector for it to UIView setAnimationDidStopSelector.

For example:

-(void) messageSlideFinished {
 // do some stuff here
}

Then when setting up the animation you would do

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(messageSlideFinished)];
like image 30
gdawg Avatar answered Dec 24 '22 12:12

gdawg