国产探花免费观看_亚洲丰满少妇自慰呻吟_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; } }];

}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 元谋县| 探索| 若尔盖县| 天门市| 武川县| 秀山| 花莲市| 上思县| 绍兴市| 南郑县| 图们市| 建德市| 凭祥市| 龙口市| 育儿| 邻水| 广州市| 阳谷县| 金川县| 阿拉尔市| 泽普县| 广宁县| 准格尔旗| 乌兰察布市| 潼南县| 九台市| 马山县| 皮山县| 海林市| 江油市| 历史| 双辽市| 潜山县| 广南县| 博罗县| 巴林左旗| 潮州市| 丽水市| 称多县| 甘谷县| 闽侯县|