0

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
4

1 回答 1

0

我的问题有一个错误。很抱歉。在实际代码中,不知何故#import "OverlayViewController.h被省略了。

MyViewController.h

#import <UIKit/UIKit.h>

#import "OverlayViewController.h"
于 2013-02-22T15:19:57.650 回答