View之间方法,变量交互(Delegate方式)
来源:互联网 发布:ubuntu升级网卡驱动 编辑:程序博客网 时间:2024/06/10 14:39
Object-c里的delegate代理始终没有彻底弄懂。恰巧需要研究各个VIEW之间相互调用方法的问题。实现了简单的delegate方法。
1.定义代理的协议
@protocol MyFunctionsDelegate-(void)delegateMethod;@end
2.View1中声明使用此协议,并在implementation中实现协议方法
@interface View1 : UIViewController <MyFunctionsDelegate>@implementation infoTableViewController-(void)delegateMethod{ NSLog(@"delegateMethod");}
3.View2中定义delegate指针
@interface View2 : UITableViewController{ id delegate;}@property(nonatomic,retain) id delegate;@end@implementation View2 @synthesize delegate;
4.View1转换到View2过程时,给delegate指明代理
View2.delegate=self;
5.View2中调用代理方法
[delegate delegateMethod];
- View之间方法,变量交互(Delegate方式)
- 利用 Delegate Design Pattern 进行 View Controller 之间的沟通
- View & Delegate
- iOS 对象之间的通信方式(delegate、block、NSNotification、kvc、kvo)总结
- WinForm窗体之间交互的一些方法(转)
- Android 和 javascript 之间交互(方法相互调用)
- iOS 用delegate方式实现页面之间的传值
- ajax与servlet之间的交互方式
- IOS学习之页面之间的传值方式(Delegate/NSNotification/Block/NSUserDefault ,单例模式)
- view之间传递数据的方式
- jQuery中.bind()、.live()和.delegate()方法之间的区别
- 1类之间通信的常用方法Block、Notification、Delegate
- iOS ViewController之间传值方法四(利用Delegate)
- MFC中MFC中 Doc 和 View之间的交互
- qt delegate createEditor()方法
- 两个对象之间很好的交互方法!
- WinForm窗体之间交互的一些方法
- WinForm窗体之间交互的一些方法
- 线程编程知识[转载]
- Download png picture
- 大明北伐討元檄文
- swfupload介绍
- Unity3d 截图保存
- View之间方法,变量交互(Delegate方式)
- POJ 3258
- 张孝祥正在整理Java就业面试题大全
- 反转一个链表。递归算法
- Windows Phone 7 Custom Message Box
- Foursquare推出全新签到历史页面 增强本地化搜索功能
- android.os.Debug调试工具使用方法
- SQL Server 2008中的新日期数据类型
- “吸血鬼数字”