代理

<span style="font-family:Arial, Helvetica, sans-serif;">代理页面  以及代理方法  </span>
<span style="font-family: Arial, Helvetica, sans-serif;">#import <UIKit/UIKit.h></span>
@class KKKKViewController;
@protocol ShareActionDelegate<NSObject>
@optional
//返回之前页面
-(void)dismissPopupJK;
@end

@interface KKKKViewController : UIViewController
@property (nonatomic, retain)id <ShareActionDelegate> delegate;

@end
#import "KKKKViewController.h"

@interface KKKKViewController ()

@end

@implementation KKKKViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton *button_getMessage;
    button_getMessage = [[UIButton alloc]init];
    button_getMessage.layer.borderColor = [UIColor whiteColor].CGColor;
    button_getMessage.layer.borderWidth = 1.8;
    //    button_getMessage.layer.cornerRadius =
    button_getMessage.backgroundColor = [UIColor blueColor];
    button_getMessage.frame = CGRectMake(10, 10, 20, 20);
    [button_getMessage setTitle:@"X" forState:UIControlStateNormal];
    [button_getMessage addTarget:self action:@selector(dismissPopup) forControlEvents:UIControlEventTouchUpInside];
    button_getMessage.layer.cornerRadius = 10;
    [self.view addSubview:button_getMessage];
}
-(void)dismissPopup{
    if ([self.delegate respondsToSelector:@selector(dismissPopupJK)]) {
        [self.delegate dismissPopupJK];
    }
}



实现方法

- (void)viewDidLoad {
   UIButton* button_write = [[UIButton alloc]init];
    button_write.backgroundColor = [UIColor redColor];
    button_write.frame = CGRectMake(0, 80, 130, 25);
    button_write.layer.cornerRadius = 10;
    [button_write addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button_write];
}
- (void)buttonAction:(id)sender {
    KKKKViewController *samplePopupViewController = [[KKKKViewController alloc] initWithNibName:@"KKKKViewController" bundle:nil];
    samplePopupViewController.delegate = self;

    [self presentViewController:samplePopupViewController animated:YES completion:nil];
}
-(void)dismissPopupJK
{
    [self dismissViewControllerAnimated:YES completion:nil];
    NSLog(@"跳转页面");
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值