Sealyu

          --- 博客已遷移至: http://www.sealyu.com/blog

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks

          Yes! There is a way of using the backBarButton with a custom action. No, it’s not by overriding the backBarButton property of navigationItem. This is not an ugly solution with images that simulate the “Back”-button (arrow-shaped.) It’s possible to use the backBarButton for popping the current viewController as normal, but than with other animations such as UIViewAnimationTransitionCurlDown.

          Enough said, the solution is simple. You have to subclass your navigationController’s  popViewControllerAnimated:(BOOL)animated. So create a custom navigationController:

          customNavigationController.h

          #import
          @interface customNavigationController : UINavigationController {}
          @end

          And a custom “popViewControllerAnimated:(BOOL)animated”, this popViewControllerAnimated-function uses the “UIViewAnimationTransitionCurlDown” when popping from a SettingsTableView.

          customNavigationController.m

          #import "customNavigationController.h"
          #import "SettingsTableController.h"
           
          @implementation customNavigationController
           
          - (UIViewController *)popViewControllerAnimated:(BOOL)animated
          {
          if([[self.viewControllers lastObject] class] == [SettingsTableController class]){
           
          [UIView beginAnimations:nil context:NULL];
          [UIView setAnimationDuration: 1.00];
          [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
          forView:self.view cache:NO];
           
          UIViewController *viewController = [super popViewControllerAnimated:NO];
           
          [UIView commitAnimations];
           
          return viewController;
          } else {
          return [super popViewControllerAnimated:animated];
          }
          }
          @end

          Use your custom navigationController in your appDelegate:

          customNavigationController *navigationController =
          [[customNavigationController alloc]
          initWithRootViewController:rootView];

          posted on 2010-11-13 23:12 seal 閱讀(629) 評論(0)  編輯  收藏 所屬分類: iPhone
          主站蜘蛛池模板: 乐安县| 万载县| 余干县| 汉沽区| 大化| 正定县| 哈巴河县| 紫阳县| 吉首市| 海城市| 云南省| 绍兴市| 盐亭县| 高平市| 鄂州市| 特克斯县| 革吉县| 兴业县| 遵化市| 颍上县| 鲁甸县| 阿瓦提县| 抚远县| 亳州市| 遵化市| 潞城市| 额尔古纳市| 理塘县| 贵阳市| 定日县| 堆龙德庆县| 长顺县| 长沙市| 新密市| 乡宁县| 子长县| 洮南市| 沅江市| 闻喜县| 安龙县| 中宁县|