开发者社区> 问答> 正文

关于从UIButton选择器调用方法

怎么从按钮选择器中调用方法?

有如下代码:

- (void)displayEditorForImage:(UIImage *)imageToEdit
{
    AFPhotoEditorController *editorController = [[AFPhotoEditorController alloc] initWithImage:imageToEdit];
    [editorController setDelegate:self];
    [self presentViewController:editorController animated:YES completion:nil];
}

UIButton调用的:

//edit button
UIButton *editButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[editButton addTarget:self
               action:@selector(editBtnTouch)
     forControlEvents:UIControlEventTouchDown];
[editButton setTitle:@"Effects" forState:UIControlStateNormal];
**// the following line shows the selector where I'm unsure how to call the method from the code above**
if ([[UIScreen mainScreen] respondsToSelector:@selector(displayEditorForImage:)] &&
        ([UIScreen mainScreen].scale == 2.0)) {
        // Retina display
        editButton.frame = CGRectMake(220.0, 320.0, 60.0, 40.0);
} else {
    editButton.frame = CGRectMake(220.0, 315.0, 60.0, 40.0);
}
[self.view addSubview:editButton];

展开
收起
爵霸 2016-03-19 08:49:32 2024 0
0 条回答
写回答
取消 提交回答
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载