我需要在操作表按钮上添加图像,所以我使用了以下代码
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];
输出
但我的问题是实现这个目标的正确方法吗? 意味着Apple会在appstore上接受我的应用吗?
答案 0 :(得分:3)
如果您想将应用程序放在AppStore上,请不要使用私有API。 Apple将拒绝使用私有API的应用程序。
根据UIActionSheet Documentation:
UIActionSheet不是设计为子类,也不应该添加 查看其层次结构。如果您需要提供更多的表格 自定义比UIActionSheet API提供的,您可以创建 你自己并以模态呈现它 presentViewController:动画:完成:
作为替代方式,您可以将自定义UIView
与UIButtons
一起使用。显示时,您可以禁用父视图的触摸事件,以便它与操作表一样。
答案 1 :(得分:2)