objective-c 协议和委托
来源:互联网 发布:rc4解密算法 编辑:程序博客网 时间:2024/05/17 04:11
objective-c protocol delegate
@protocol UIBViewDelegate <NSObject>
@optional
- (void)ontouch:(UIScrollView *)scrollView;//声明协议方法
@end
@interface BView : UIScrollView<UIScrollViewDelegate>
{
id< UIBViewDelegate > _touchdelegate;//设置委托变量
}
@property(nonatomic,assign) id< UIBViewDelegate > _touchdelegate;
@end
B_View.mm:
@synthesize _touchdelegate;
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
_touchdelegate=nil;
}
return self;
}
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
[super touchesBegan:touches withEvent:event];
if(_touchdelegate!=nil && [_touchdelegate respondsToSelector: @selector(ontouch:) ] == true)
[_touchdelegate ontouch:self];//调用协议委托
}
@interface AViewController : UIViewController < UIBViewDelegate >
{
BView *m_BView;
}
A_View.mm:
- (void)viewWillAppear:(BOOL)animated
{
m_BView._touchdelegate = self;//设置委托
[self.view addSubview: m_BView];
}
- (void)ontouch:(UIScrollView *)scrollView
{
//实现协议
}
- objective-c 协议和委托
- objective-c 协议和委托
- objective-c 协议和委托
- Objective-C协议和委托
- 详解Objective-C中委托和协议
- Objective-C中委托和协议详解
- Objective-C中协议和委托
- 详解Objective-C中委托和协议
- 浅谈Objective-C协议和委托
- 详解Objective-C中委托和协议
- 详解Objective-C中委托和协议
- 详解Objective-C中委托和协议
- 浅谈Objective-C协议和委托
- Objective-C中协议和委托
- 详解Objective-C中委托和协议
- 详解Objective-C中委托和协议
- Objective-C中协议和委托简述
- Objective-C中委托和协议
- Base64编码(汇编版,未做过多优化,性能自认为还可以)
- Visual C++实现局域网IP多播
- C++中指向成员的指针
- 看有没有高手能解决这个SQL远程连接失败问题
- quicksort快速排序
- objective-c 协议和委托
- Visual C++中检测和隔离内存泄漏
- musca+conky+tint2+stalonetray组合而成的日常桌面
- 转 在TreeView中操作节点CheckBox需要注意的
- Java 正则匹配 字符串取出
- 错误日志System.log写入问题
- IE script debug 工具
- 行专列
- J2EE包结构规范