neh*_*eha 4 iphone objective-c ios
Apple拒绝了我的应用,因为:
3.3.1应用程序只能以Apple规定的方式使用Documented API,不得使用或调用任何私有API.应用程序必须最初使用Objective-C,C,C++或JavaScript编写,由iPhone OS WebKit引擎执行,并且只有使用C,C++和Objective-C编写的代码可以编译并直接链接到Documented API(例如,禁止通过中间翻译或兼容性层或工具链接到Documented API的应用程序.
您的应用程序中包含的非公共API是animationDidStop:finished:context:.
这是我使用上述方法调用的方法:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
我正在使用此方法在某个事件发生后显示滑动消息.
但我没有定义这种方法.当我试图找到它时,只能在CAAnimation.h,UIView.h中找到它.
有没有人遇到同样的问题?你怎么修好它的?
整个问题setAnimationDidStopSelector:是,当动画完成时,您告诉系统调用您自己的自定义方法.所以,如果要传入该选择器,则需要自己在类中定义该方法:
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
// do whatever.
}
Run Code Online (Sandbox Code Playgroud)
请注意文档setAnimationDidStopSelector:说你必须使用这种形式的选择器,但实际上你也可以使用像疯狗描述的更短的选择器.但是,最好是检查animationID和context以及其他项目.
您需要将该方法添加到代码所在的任何类中,因为您将self作为动画委托传递.
由于某些原因,它们可能还有一个同名的内部UIView方法,这就是为什么你被指责使用未记录的API.
小智 5
如果您需要在动画完成时执行某些操作(如释放对象),则应定义自己的方法,然后将选择器传递给UIView setAnimationDidStopSelector.
例如:
-(void) messageSlideFinished {
// do some stuff here
}
然后在设置动画时你会这样做
[UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(messageSlideFinished)];