PhotoPicker 示例代码使用覆盖视图。下面是我在我的应用程序中使用的 PhotoPicker 的一些相关代码,但我想使用ARC,而 PhotoPicker 不使用 ARC。我想我已经设法解决了 PhotoPicker 和 ARC 之间的其他冲突,但不是这个。
当OverlayViewController.h
我按原样使用下面的行时id <OverlayViewControllerDelegate> delegate;
,我得到了错误Existing ivar 'delegate' for property 'delegate' with assign attribute must be __unsafe_unretained
。
OverlayViewController.h
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioServices.h>
@protocol OverlayViewControllerDelegate;
@interface OverlayViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
{
id <OverlayViewControllerDelegate> delegate; // **THIS IS THE KEY LINE**
}
@property (nonatomic, assign) id <OverlayViewControllerDelegate> delegate;
@property (nonatomic, retain) UIImagePickerController *imagePickerController;
- (void)setupImagePicker:(UIImagePickerControllerSourceType)sourceType;
@end
@protocol OverlayViewControllerDelegate
- (void)didTakePicture:(UIImage *)picture;
- (void)didFinishWithCamera;
@end
但是当我按照这里的建议,或者注释掉那一行或者在那一行前面加上__unsafe_unretained
,我就得到了问题Cannot find protocol declaration for 'OverlayViewControllerDelegate'; did you mean 'UISplitViewControllerDelegate'?
。MyViewController.h
MyViewController.h
#import <UIKit/UIKit.h>
#import "OverlayViewController.h"
@interface MyViewController : UIViewController <UIImagePickerControllerDelegate, OverlayViewControllerDelegate>
@end