文章标题
来源:互联网 发布:java连接zookeeper报错 编辑:程序博客网 时间:2024/06/14 02:21
界面传值<协议六步>
准备工作
#import "AppDelegate.h"#import "RootViewController.h"@interface AppDelegate ()@end@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor=[UIColor whiteColor]; [self.window makeKeyAndVisible]; RootViewController *rootVC=[[RootViewController alloc] init]; UINavigationController *naVC=[[UINavigationController alloc] initWithRootViewController:rootVC]; self.window.rootViewController=naVC; return YES;}
协议六部开始
1.在SecondViewController.h中声明一套协议
//一.声明一套协议@protocol SecondViewControllerDelete <NSObject>-(void)bringStr:(NSString *)str;@end
2.写属性
//二.设置代理人属性@property(nonatomic,assign)id<SecondViewControllerDelete>delgate;
3.在SecondViewController.m设值代理人执行方法
//三.设置代理人执行的方法 [self.delgate bringStr:self.textField.text];
4.在RootViewController.m签协议
@interface RootViewController ()<SecondViewControllerDelete>
5.设置代理人
//五.设置代理人 secVC.delgate=self;
6.实现方法
//六.实现协议方法-(void)bringStr:(NSString *)str{ NSLog(@"2333333"); NSLog(@"%@",str); self.textField.text=str;}
属性传值三部
//属性传值需要把前一页的值给后一页,也就是后一页要有一个相应的属性来接受前一页的内容
1.在SecondViewController.h
//1.写一个类型相符的属性,来接受结果@property(nonatomic,copy)NSString *str;
2.在RootViewController.m中
//2.把前一页的值传给后一页的属性来接收 secVC.str=self.textField.text;
3.在SecondViewController.m使用
//3.使用属性 self.textField.text=self.str;
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- S3C2440存储控制器和MMU浅析
- DP---求给定矩阵中最大正方形的维度
- git 的基本用法
- 插入排序
- 设计模式六大原则(4):接口隔离原则
- 文章标题
- 【重走普及路】【分治】【经典算法】快速幂
- 贪吃蛇详解Windows编程(一)
- 徒手撸筛选法求素数
- 在windows环境下,使用Eclipse和gcc-Linaro工具链,对BeagleBone进行交叉编译和远程部署
- Boost学习笔记(2)
- BFPRT 算法java实现
- Hibernate Validation使用示例及讲解
- IOS cocoapods 第三方库的管理工具