页面传值

页面传值:从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



转载于:https://my.oschina.net/simple2012/blog/625989

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值