iOS简单的利用代理传值
来源:互联网 发布:淘宝如何增加访客 编辑:程序博客网 时间:2024/05/21 04:16
seconderViewController.h 里面需要实现
#import <UIKit/UIKit.h>
@protocol messageDelegate <NSObject>
@optional
- (void)messageSender:(NSString *)string;
@end
@interface seconderViewController :UIViewController
@property (nonatomic,weak)id<messageDelegate>delegate;
@end
seconderViewController.m 里面需要实现
#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:^{
}];
}
ViewController.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{
[selfpresentViewController:sencoderVCanimated:YEScompletion:^{
}];
}
- (void)messageSender:(NSString *)string{
lable.text = string;
}
- iOS简单的利用代理传值
- iOS简单代理反向传值
- android中利用代理模式简单实现界面之间的跳转与传值
- iOS - 代理协议,正向或逆向传值,属性传值的简单实用
- iOS开发中代理的简单理解
- 【iOS开发-26】利用协议代理实现导航控制器UINavigationController视图之间的正向传值和反向传值
- 【iOS开发-26】利用协议代理实现导航控制器UINavigationController视图之间的正向传值和反向传值
- IOS之简单代理
- ios 代理传值
- iOS 代理传值
- iOS代理传值
- iOS 代理传值
- iOS 代理传值
- IOS--代理传值
- ios代理传值
- iOS 代理传值
- ios代理传值
- 利用代理模式进行页面之间的传值
- 【内容】css3点击区域4种全屏放大显示内容动画特效
- 启动activity的过程追踪
- 安装mysql Install/Remove of the Service Denied!错误的解决办法
- 致我已逝的青春年少
- 【程序员】:程序员经常去的社区
- iOS简单的利用代理传值
- 创建数据库并授权
- dfs剪枝1
- JAVA定时任务Quartz
- lua语言入门之Sublime Text设置lua的Build System
- 关于qmail的笔记
- 属性“GetModels”的值为 null、未定义或不是 Function 对象
- QtQuick一分钟技巧:使用C++保存全局数据
- 欢迎使用CSDN-markdown编辑器