【发布时间】:2023-03-03 13:36:02
【问题描述】:
环境:运行 iOS 8.0 SDK 的 Xcode 版本 6.0 (6A254o)
我正在尝试将主 UIViewController(呈现控制器)作为代表分配给呈现的弹出 UIViewController:
#import "MainViewController.h"
#import "OrangeViewController.h"
#import "MessageViewController.h"
@interface MainViewController () <UIAdaptivePresentationControllerDelegate>{
OrangeViewController *orangeVC;
MessageViewController *msgVC;
}
@property (weak, nonatomic) IBOutlet UIBarButtonItem *helpBarItem;
@end
@implementation MainViewController
...
- (void)viewDidLoad {
[super viewDidLoad];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIPopoverPresentationController *msgPC = [msgVC popoverPresentationController];
msgPC.barButtonItem = self.helpBarItem;
msgPC.delegate = self; <-- incompatible type
msgPC.permittedArrowDirections = UIPopoverArrowDirectionAny;
msgVC.preferredContentSize = CGSizeMake(260.0, 240.0);
}
但是,我得到了一个不兼容的委托分配:
...MainViewController.m:40:20: 分配给 来自不兼容类型的“id” 'MainViewController *const __strong'
如何将 MainViewController (self) 从“const-strong”更改为与 UIPopover 视图控制器兼容的内容(或通过最佳解决方案)?
【问题讨论】:
-
请检查您的 MainViewController 类是否符合
协议。
标签: ios objective-c delegates uipopovercontroller