gpt4 book ai didi

ios - 使用私有(private) API 自定义 UIActionSheet

转载 作者:行者123 更新时间:2023-11-28 18:34:54 25 4
gpt4 key购买 nike

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

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上接受我的应用程序吗?

最佳答案

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

根据 UIActionSheet Documentation :

UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with presentViewController:animated:completion:.

作为替代方法,您可以将自定义的 UIView 与这些 UIButtons 一起使用。当它显示时,你可以禁用父 View 的触摸事件,这样它就和action-sheet一样。

这是一个例子:Display a custom UIView like a UIActionSheet

关于ios - 使用私有(private) API 自定义 UIActionSheet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20882299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com