使用私有API的UIActionSheet自定义

时间:2014-01-02 11:50:44

标签: ios uiactionsheet

我需要在操作表按钮上添加图像,所以我使用了以下代码

UIActionSheet *actionSheetObject = [[UIActionSheet alloc] initWithTitle:@"Follow Us" delegate:self cancelButtonTitle:kCancel destructiveButtonTitle:nil otherButtonTitles:@"Twitter",@"Facebook",@"Blog",@"LinkedIn",nil];
[[[actionSheetObject valueForKey:@"_buttons"] objectAtIndex:0] setImage:[UIImage imageFromBundle:@"TwitterIcon"] forState:UIControlStateNormal];
[[[actionSheetObject valueForKey:@"_buttons"] objectAtIndex:1] setImage:[UIImage imageFromBundle:@"FacebookIcon"] forState:UIControlStateNormal];
[[[actionSheetObject valueForKey:@"_buttons"] objectAtIndex:2] setImage:[UIImage imageFromBundle:@"BlogIcon"] forState:UIControlStateNormal];
[[[actionSheetObject valueForKey:@"_buttons"] objectAtIndex:3] setImage:[UIImage imageFromBundle:@"LinkedInIcon"] forState:UIControlStateNormal];
[actionSheetObject showInView:self.view];

输出 enter image description here

但我的问题是实现这个目标的正确方法吗? 意味着Apple会在appstore上接受我的应用吗?

2 个答案:

答案 0 :(得分:3)

如果您想将应用程序放在AppStore上,请不要使用私有API。 Apple将拒绝使用私有API的应用程序。

根据UIActionSheet Documentation

  

UIActionSheet不是设计为子类,也不应该添加   查看其层次结构。如果您需要提供更多的表格   自定义比UIActionSheet API提供的,您可以创建   你自己并以模态呈现它   presentViewController:动画:完成:

作为替代方式,您可以将自定义UIViewUIButtons一起使用。显示时,您可以禁用父视图的触摸事件,以便它与操作表一样。

以下是一个示例:Display a custom UIView like a UIActionSheet

答案 1 :(得分:2)

99.9%是Apple会接受这个,因为编译器不会检测到没有关于此的警告,但还有其他问题,Apple可以更改UIActionSheet中的变量名称,我的意思是,这段代码有风险,但肯定会工作并通过Apple验证。

相关问题