我有一些困难找出我做错了什么时试图为我的UIPopoverView分配我的委托。我试图解决甚至不使用一个,但它会更直接和干净。下面是我认为应该包括它的代码:UIPopover委托 - 无法分配,无论协议/声明
//.h of View where I call popover, this would be the delegate.
#import <UIKit/UIKit.h>
#import "ACTypePopoverViewController.h"
@interface NewRouteViewController : UIViewController<ACTypePickerDelegate>{
ACTypePopoverViewController *_acTypePicker;
UIPopoverController *_acTypePickerPopover;
}
@property (nonatomic, retain) ACTypePopoverViewController *acTypePicker;
@property (nonatomic, retain) UIPopoverController *acTypePickerPopover;
@end
//.m file for where I would like to use the popover, is the .m for the .h above
if (_acTypePickerPopover == nil)
{
ACTypePopoverViewController* content = [[ACTypePopoverViewController alloc] init];
UIPopoverController* aPopover = [[UIPopoverController alloc]
initWithContentViewController:content];
aPopover.delegate = self;
[content release];
// Store the popover in a custom property for later use.
self.acTypePickerPopover = aPopover;
}
[self.acTypePickerPopover presentPopoverFromRect:self.selectACTypeButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
//.h file for the actual popover, what I would be setting the delegate of
@protocol ACTypePickerDelegate
- (void)acTypeSelected:(NSString *)acType;
@end
@interface ACTypePopoverViewController : UITableViewController {
NSMutableArray *_acTypes;
NSString *selectedACType;
id<ACTypePickerDelegate> _delegate;
}
@property (nonatomic, retain) NSMutableArray *acTypes;
@property (nonatomic, retain) NSString *selectedACType;
@property (nonatomic, assign) id<ACTypePickerDelegate> delegate;
@end
我想这就是我所需要的,但让我知道,如果需要更多的代码!
谢谢!
这使得一个很大的意义,当然它现在工作。谢谢! –