利用代理模式进行页面之间的传值
来源:互联网 发布:nginx last 编辑:程序博客网 时间:2024/05/29 10:12
第一个界面.m文件需要实现
#import "ViewController.h"
#import "seconderViewController.h"
@interface ViewController ()<messageDelegate>
{
UILabel *lable;
seconderViewController *sencoderVC;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
[self.viewsetBackgroundColor:[UIColorgreenColor]];
lable = [UILabelnew];
lable.backgroundColor = [UIColorgrayColor];
lable.frame =CGRectMake(10,100, 200,50);
[self.viewaddSubview:lable];
sencoderVC = [seconderViewControllernew];
sencoderVC.delegate =self;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
sencoderVC = [seconderViewControllernew];
sencoderVC.delegate =self;
[selfpresentViewController:sencoderVCanimated:YEScompletion:^{
}];
}
- (void)messageSender:(NSString *)string{
lable.text = string;
}
第二个界面.h文件里面
#import <UIKit/UIKit.h>
@protocol messageDelegate <NSObject>
@optional
- (void)messageSender:(NSString *)string;
@end
@interface seconderViewController :UIViewController
@property (nonatomic,weak)id<messageDelegate>delegate;
@end
#import "seconderViewController.h"
@interface seconderViewController ()
{
UILabel *lable;
}
@end
@implementation seconderViewController
- (void)viewDidLoad {
[superviewDidLoad];
lable = [UILabelnew];
lable.backgroundColor = [UIColorredColor];
[lablesetText:@"王维传"];
lable.frame =CGRectMake(100,100, 200,50);
[self .viewaddSubview:lable];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self.delegatemessageSender:lable.text];
[selfdismissViewControllerAnimated:YEScompletion:^{
}];
}
- 利用代理模式进行页面之间的传值
- android中利用代理模式简单实现界面之间的跳转与传值
- iOS - 页面之间传值的实现 - 代理
- jsp 页面之间进行值的传递
- Activity之间进行页面传值
- 利用 InitializingBean Jackson的ObjectMapper 进行页面传值
- 利用dialogArguments进行网页页面传值
- 利用dialogArguments进行网页页面传值
- 两个页面之间传参数(包括单例模式,sugue,tableView,代理模式)
- 用代理方法进行视图之间的传值 B视图值传入A视图
- ios 页面之间的传值:属性传值,代理传值,block传值
- 两个页面之间通过js进行传值
- 两个页面之间通过url地址栏进行传值
- 两个页面之间通过js进行传值
- 【iOS开发-26】利用协议代理实现导航控制器UINavigationController视图之间的正向传值和反向传值
- 【iOS开发-26】利用协议代理实现导航控制器UINavigationController视图之间的正向传值和反向传值
- 代理模式-----进行事务的注解
- Android页面之间进行数据回传
- spring框架学习(一)
- C_C++指针指针应用详解
- virtualenv和virtualenvwrapper总结
- C++中的多态
- C# 自定义光标 WaitCursor
- 利用代理模式进行页面之间的传值
- 用实例给新手讲解RSA加密算法
- 转载:X264学习总结
- Swift定义一个全局变量字符串
- 推荐 10 款基于 Bootstrap 框架的扩展
- 单点登录原理
- 使用反射机制实现菜单Icon的显示
- 复习内容
- gitlab使用