iOS委托协议
来源:互联网 发布:人工智能概念股 编辑:程序博客网 时间:2024/05/14 04:44
A类 : TRRootViewController
B类 :TRSubViewController
//第1步 在B类.h文件 声明协议 制定协议
#import <UIKit/UIKit.h>
@protocol TRSubViewControllerDelegate<NSObject>
-(void)changeRootViewColor:(UIColor *)color;
@end
@interface TRSubViewController :UIViewController
@property(nonatomic,weak)id<TRSubViewControllerDelegate> delegate;
@end
//第2步 在A类.h文件 遵守委托人制定的协议
#import <UIKit/UIKit.h>
#import "TRSubViewController.h"
@interface TRRootViewController :UIViewController<TRSubViewControllerDelegate>
@end
第3步在A类.m文件 实现协议中的方法
#pragma mark - 实现协议中的方法
-(void)changeRootViewColor:(UIColor *)color
{
self.view.backgroundColor = color;
}
//第4步在B类.m文件
//B界面想修改A界面的颜色,但是没有能力去做
//让委托人去做我们想做而不能做的事
[self.delegatechangeRootViewColor:[UIColorredColor]];
转载请注明出处:http://blog.csdn.net/sevenquan
- ios委托与协议
- ios协议和委托
- ios协议与委托
- iOS 协议与委托
- IOS协议与委托
- IOS协议与委托
- ios协议和委托
- iOS 委托和协议
- iOS委托协议
- iOS 协议 委托
- iOS 委托 协议
- iOS中的协议与委托
- IOS代理协议与委托
- ios中协议与委托
- iOS中的协议与委托
- IOS中的委托和协议
- iOS中的协议与委托
- IOS代理协议与委托
- ApplicationContextAware接口的作用
- Monkey详解
- MultithreadedTC
- delphi中INI 文件的创建与使用
- GTK 滚动窗口构件(GtkScrolledWindow)
- iOS委托协议
- android 软件键盘
- SQLite数据库的使用
- HTML5之拖放属性实现图片的拖放
- 4. Median of Two Sorted Arrays leetcode python New season for 2016
- JS分页案例
- 控制器的创建和view的创建
- s5k5e2ya MIPI 摄像头调试
- ubuntu环境下的用户添加 - 指定用户shell