国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

iOS4,下實現UIView動畫結束后調用

2019-11-02 14:41:15
字體:
來源:轉載
供稿:網友

   在寫代碼時,發現原來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:)];

  

童話村電影網[www.aikan.tv/special/tonghuacundianying/]
[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];

  }

  }

  ];

  看起來更加簡潔方便了,但邏輯似乎沒有原來好理解了。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 信阳市| 安龙县| 敦化市| 宁武县| 湖北省| 娱乐| 周口市| 陇西县| 大石桥市| 绥棱县| 黎川县| 云和县| 红桥区| 乐至县| 九江县| 英超| 琼海市| 新昌县| 夹江县| 中阳县| 遂溪县| 澎湖县| 宜阳县| 札达县| 分宜县| 台中市| 邵武市| 辉县市| 伊春市| 成武县| 平和县| 张掖市| 酒泉市| 金坛市| 永登县| 柘城县| 英山县| 舞钢市| 林口县| 朝阳县| 永登县|