页面传值
2016-02-29 16:53
169 查看
页面传值:从A到B,然后从B回传到A。只需要实现IUINavigationControler协议
#import <UIKit/UIKit.h> #pragma mark - #pragma mark - IUINavigationContoller /** *@protocol *IUINavigationController *@discussion */ @protocol IUINavigationController <NSObject> @required ///导航到页面并携带参数 - (void)NavigateTo:(NSDictionary *)param withFromClassName:(Class)c; ///返回到页面并携带参数 - (void)NavigateBack:(NSDictionary *)param withFromClassName:(Class)c; @end #pragma mark - #pragma mark - UINavigationControllerExtends /** *@class *UINavigationController 类 *@discussion */ @interface UINavigationController (UINavigationControllerExtends) ///跳转到页面,并携带参数 - (void)naviagteToWithPageName:(NSString *)name withParam:(NSDictionary *)params; ///跳转到页面 - (void)naviagteToWithPageName:(NSString *)name; ///返回页面,并携带参数 - (void)goBackWithParam:(NSDictionary *)params; ///返回页面 - (void)goBack; @end
#import "UINavigationController+UINavigationControllerExtends.h" #import "Utils.h" @implementation UINavigationController (UINavigationControllerExtends) - (void)naviagteToWithPageName:(NSString *)name withParam:(NSDictionary *)params{ UIViewController *vc = [self CreateVCWithXIB:name]; if ([vc conformsToProtocol:@protocol(IUINavigationController)]) { id<IUINavigationController> navigate = (id<IUINavigationController>)vc; [navigate NavigateTo:params withFromClassName:[self.visibleViewController class]]; NSLog(@"跳转到%@页面,携带参数%@",name,params); } [self myAnimationPush]; [self pushViewController:vc animated:NO]; } - (void)naviagteToWithPageName:(NSString *)name{ UIViewController *vc = [self CreateVCWithXIB:name]; NSLog(@"%@",vc); [self myAnimationPush]; [self pushViewController:vc animated:NO]; } - (void)goBackWithParam:(NSDictionary *)params{ Class c = [self.visibleViewController class]; [self myAnimationPop]; [self popViewControllerAnimated:NO]; UIViewController *vc = self.visibleViewController; if ([vc conformsToProtocol:@protocol(IUINavigationController)]) { id<IUINavigationController> navigate = (id<IUINavigationController>)vc; [navigate NavigateBack:params withFromClassName:c]; NSLog(@"返回页面%@传递参数%@",c,params); } } - (void)goBack{ // [self myAnimationPop]; // [self popViewControllerAnimated:NO]; [self goBackWithParam:nil]; } - (UIViewController *)CreateVCWithXIB:(NSString *)xibName{ UIViewController *control=[(UIViewController *)[NSClassFromString(xibName) alloc] init]; return control; } - (void)myAnimationPush{ // CATransition *animation = [CATransition animation]; // animation.duration = 0.5f; // animation.timingFunction = UIViewAnimationCurveEaseInOut; // animation.fillMode = kCAFillModeForwards; // animation.type = @"rippleEffect"; // animation.subtype = kCATransitionFromRight; // [self.view.layer addAnimation:animation forKey:@"animation"]; } - (void)myAnimationPop{ // CATransition *animation = [CATransition animation]; // animation.duration = 0.3f; // animation.timingFunction = UIViewAnimationCurveEaseInOut; // animation.fillMode = kCAFillModeForwards; // animation.type = @"cameraIris"; // animation.subtype = kCATransitionFromRight; // [self.view.layer addAnimation:animation forKey:@"animation"]; } @end
相关文章推荐
- Leangoo:用敏捷开发管理思维做团队协作的SaaS软件
- linux批量删除多级目录下同一格式的文件
- maven 多套环境 配置(开发、测试、预发、正式)
- IMP-00003: ORACLE error 3113 encountered ORA-03113: end-of-file on communication channel
- 数字密码发生器
- Nginx配置文件详细说明
- poj1703--Find them, Catch them(并查集应用)
- WHU1124 Football Match
- 软件工程概论初学
- 老李分享:JVM调优
- Android Studio学习总结
- 设计模式(8)--模板模式
- ES6 Class
- 关于androidannotations(注解)的理解和使用(文档篇)
- cocos2d-js cocos run -p android 报错:文件名、目录名卷标语法不正确
- 二叉树学习之二叉树的构建及操作
- 一个IOS弹出窗口时的小技巧
- android BaseAdapter 自定义适配器 BaseAdapter基类抽取 一
- 你百度不到的android坑 imageview.setimageDrawable和setbackgroundDrawable
- 迷茫了