主要涉及到两个文件。
第一个文件,我称之为定义delegate的文件,要做的事:
1. 在BorderDetectionViewController.h中做两件事
(1)
@protocol BorderDetectionViewControllerDelegate <NSObject>
- (void)dismissBorderDetectionView;
@end
(2)
@property (nonatomic, assign) id<BorderDetectionViewControllerDelegate> delegate;
2.在BorderDetectionViewController.m中做两件事
(1)
@synthesize delegate;
(2)
[self.delegate dismissBorderDetectionView];
在第二个文件中,我称之为应用文件,要做的事:
1. 在MainTabViewController.h中做两件事:
(1)
#import "BorderDetectionViewController.h"
(2)
在interface后面加上<BorderDetectionViewControllerDelegate>
2. 在MainTabViewController.m中做两件事:
(1)在要present borderView时,设置borderViewController.delegate = self;
(2)实现该delegate函数
- (void)dismissBorderDetectionView
{
[self dismissModalViewControllerAnimated:YES];
}
定义delegate与应用文件整合技术

本文详细介绍了如何在iOS开发中定义delegate并应用于不同文件之间的通讯,通过具体实例展示了如何在ViewController中设置delegate和实现特定delegate方法。
3557

被折叠的 条评论
为什么被折叠?



