【学习笔记】AB传
来源:互联网 发布:女友花钱大手大脚 知乎 编辑:程序博客网 时间:2024/06/07 19:04
//
// AAAViewController.h
#import <UIKit/UIKit.h>
#import "BBBViewController.h"
@interface AAAViewController :UIViewController
{
UILabel*label; //传label的标题声明全局
}
@end
//
// AAAViewController.m
#import "AAAViewController.h"
@interface AAAViewController ()
@end
@implementation AAAViewController
- (void)viewDidLoad {
[superviewDidLoad];
////////////建立button,从AAA推送到BBB视图
UIButton*button1=[[UIButtonalloc]initWithFrame:CGRectMake(105,100,50, 30)] ;
[button1 setBackgroundColor:[UIColorredColor]];
[button1 setTitle:@"BBB"forState:UIControlStateNormal];
[button1 addTarget:selfaction:@selector(GOBBB)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:button1];
///////////传label的标题///////////
label=[[UILabelalloc]initWithFrame:CGRectMake(50,255,200, 40)];
label.text=@"yiuhuohuoho";
label.backgroundColor=[UIColoryellowColor];
[self.viewaddSubview:label];
}
///////////PUSH 方法,加传值的方法///////////
-(void)GOBBB
{
BBBViewController*bbbView=[[BBBViewControlleralloc]init];
bbbView.mystr =label.text; //传值关键
[self.navigationControllerpushViewController:bbbViewanimated:YES];
}
@end
//
// BBBViewController.h
#import <UIKit/UIKit.h>
@interface BBBViewController :UIViewController
@property (nonatomic,copy)NSString *mystr; //设置变量,复制保存从AAA传来的label标题,而且是字符串
@end
//
// BBBViewController.m
#import "BBBViewController.h"
@interface BBBViewController ()
@end
@implementation BBBViewController
- (void)viewDidLoad {
[superviewDidLoad];
UILabel*label=[[UILabelalloc]initWithFrame:CGRectMake(50,200,200, 40)];
label.text=self.mystr; //完成传值
label.backgroundColor=[UIColoryellowColor];
[self.viewaddSubview:label];
UIButton*button=[[UIButtonalloc]initWithFrame:CGRectMake(50,300, 200, 30)];
[button setTitle:self.mystrforState:UIControlStateNormal]; //完成传值,可以多传,注意用self.mystr
button.backgroundColor=[UIColorredColor];
[self.viewaddSubview:button];
}
@end
- 【学习笔记】AB传
- G.729AB学习笔记
- 【学习笔记】AB调方法
- linux0.11学习笔记-技术铺垫-简单AB任务切换程序(3)-调试手段和方法
- linux0.11学习笔记-技术铺垫-简单AB任务切换程序(5)-实现三个任务切换
- 【学习笔记】系列八:Web性能压力测试工具之ApacheBench(ab)详解
- apache ab压力测试学习
- ab.
- ab
- ab
- ab
- ab
- ab
- ab
- ab
- linux0.11学习笔记-技术铺垫-简单AB任务切换程序(1)-实现一个简单的bootloader
- linux0.11学习笔记-技术铺垫-简单AB任务切换程序(2)-可加载执行其他程序的bootloader
- linux0.11学习笔记-技术铺垫-简单AB任务切换程序(4)-向现存写数据并响应时钟中断
- java程序打包后文件图片不能加载的问题
- Android实现下拉刷新,滑动加载更多的功能
- Redis 事务
- IAR 8.10.1 中无法go to defination of ...
- XCode使用注意之-LibrarySearchPath与FramewrokSearchPath
- 【学习笔记】AB传
- 四、JAVA异常处理
- 5.4.4 Java的常用包
- 使用ActionBar,调整Theme时遇到You need to use a Theme.AppCompat theme (or descendant) with this activity解决方法
- Oracle 表空间、用户、角色、授权
- 题5Longest Palindromic Substring
- LoaderManager.LoaderCallbacks使用实例
- http://www.2cto.com/kf/201402/280576.html
- HttpClient的使用