我知道我可以双击IKImageView并打开编辑面板。在Objective C中我可以做到这一点
- (IBAction)editPanel:(id)sender {
IKImageEditPanel *editor = [IKImageEditPanel sharedImageEditPanel];
[editor setFrameOrigin:NSMakePoint(400,200)];
[editor setDataSource:imageView]; // Here imageView is your IKImageView.
[editor makeKeyAndOrderFront:nil];
}
但是,当我尝试在swift中设置数据源时,我收到一条错误消息,说我无法分配这种类型的IKImageView!到IKImageEditPanelDataSource类型的值!
这是我的代码:
@IBAction func adjustments(sender: NSToolbarItem) {
let editor = IKImageEditPanel.sharedImageEditPanel()
editor.setFrameOrigin(NSPoint(x: 400, y: 200))
editor.dataSource = imageView //Error on this line
editor.makeKeyAndOrderFront(nil)
}
答案 0 :(得分:1)
来自苹果论坛......
我需要告诉IKImageView它应该符合IKImageEditPanelDataSource。 (它已经这样做了,但我必须明确地对编译器这么安静地说。)
在任何班级之外......
extension IKImageView: IKImageEditPanelDataSource {
}