足球游戏_中国足彩网¥体育资讯$

ios4下实现uiview动画结束后调用
来源:易贤网 阅读:684 次 日期:2015-02-03 14:29:44
温馨提示:易贤网小编为您整理了“ios4下实现uiview动画结束后调用”,方便广大网友查阅!

在写代码时,发现原来3.1.3下经常用的uiview动画结束后调用事件的方法居然不起作用了,摸索了一下,发现ios4下对uivew的animation处理已经有新的方式了,和大家分享一下:

代码功能:在myview向下移出屏幕的动画结束后,触发事件再将myview移除掉。

ios4以前的用法:

[uiview beginanimations:@view remove context:nil];

uiview setanimationdelegate:self];

[uiview setanimationdidstopselector:@selector(animationfinish:animationid:finished:context:)];

[uiview setanimationduration:0.3f];

[uiview setanimationcurve:uiviewanimationcurvelinear];

myview.center = cgpointmake(myview.center.x, myview.center.y+480.0);

uiview commitanimations];

- (void)animationfinish:(nsstring *)animationid finished:(nsnumber *)finished context:(void *)context {

if (animationid == @view remove) {

[myview removefromsuperview];

}

}

xcode的document已经明确说了setanimationdidstopselector :”use of this method is discouraged in iphone os 4.0 and later. you should use the block-based animation methods instead.“,看来这种方法是行不通了,反正在我的模拟器上是不行了,以下是ios4中的实现方法:

[uiview animatewithduration:0.3 delay:0 options:uiviewanimationoptioncurvelinear

animations:^{

settingview.center = cgpointmake(myview.center.x, myview.center.y+480.0);

}

completion:^(bool finished){

if (finished){

[myview removefromsuperview];

}

}

];

看起来更加简洁方便了,但逻辑似乎没有原来好理解了。

中国足彩网信息请查看IT技术专栏

中国足彩网信息请查看技术文章
易贤网手机网站地址:ios4下实现uiview动画结束后调用
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标