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

首頁 > 系統 > iOS > 正文

iOS addChildViewController方法

2019-11-09 17:18:21
字體:
來源:轉載
供稿:網友

單獨使用 addSubview 去加viewController的view發現有許多問題,主要是使用了代理方法的。查了下發現問題所在。 蘋果新的API增加了addChildViewController方法,并且希望我們在使用addSubview時,同時調用[self addChildViewController:child]方法將sub view對應的viewController也加到當前ViewController的管理中。 對于那些當前暫時不需要顯示的subview,只通過addChildViewController把subViewController加進去;需要顯示時再調用transitionFromViewController方法。將其添加進入底層的ViewController中。

//點擊切換頁面 - (void)didClick:(UIButton *)button { // 點擊處于當前頁面的按鈕,直接跳出 其他頁面 [self replaceController:self.currentVC newController:self.firstVC];

}

// 切換各個標簽內容 - (void)replaceController:(UIViewController )oldController newController:(UIViewController )newController { /** * 著重介紹一下它 * transitionFromViewController:toViewController:duration:options:animations:completion: * fromViewController 當前顯示在父視圖控制器中的子視圖控制器 * toViewController 將要顯示的姿勢圖控制器 * duration 動畫時間(這個屬性,old friend 了 O(∩_∩)O) * options 動畫效果(漸變,從下往上等等,具體查看API) * animations 轉換過程中得動畫 * completion 轉換完成 */

[self addChildViewController:newController]; [self transitionFromViewController:oldController toViewController:newController duration:2.0 options:UIViewAnimationOptionTransitionCrossDissolve animations:nil completion:^(BOOL finished) { if (finished) { //移除oldController,但在removeFromParentViewController:方法前不會調用willMoveToParentViewController:nil 方法,所以需要顯示調用 [newController didMoveToParentViewController:self]; [oldController willMoveToParentViewController:nil]; [oldController removeFromParentViewController]; self.currentVC = newController; }else{ self.currentVC = oldController; } }];

}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 芦山县| 阳西县| 建阳市| 柳江县| 齐齐哈尔市| 墨玉县| 花莲市| 共和县| 长寿区| 沅江市| 勃利县| 宁远县| 玉林市| 策勒县| 巴彦淖尔市| 松溪县| 沛县| 通化市| 新巴尔虎右旗| 体育| 新安县| 汨罗市| 石狮市| 凤阳县| 富平县| 兰溪市| 罗平县| 乐平市| 松溪县| 鹤山市| 教育| 游戏| 本溪| 墨江| 留坝县| 安阳市| 佛冈县| 庆阳市| 绥化市| 侯马市| 伊川县|