gpt4 book ai didi

ios - 自定义 UIActionSheet 问题

转载 作者:行者123 更新时间:2023-11-29 02:44:22 31 4
gpt4 key购买 nike

我正在使用如下所示的自定义开源操作表:

我的问题是,当我将头文件导入到我的项目 DoActionSheet.h 时,代码中断了,所以我添加了所有“Demo”文件,代码只有在我使用时才能正常工作与演示中用于选择样式的分段控件相同,例如:

DoActionSheet *vActionSheet = [[DoActionSheet alloc] init];
vActionSheet.nAnimationType = _sgType.selectedSegmentIndex;

if (_sgStyle.selectedSegmentIndex == 0)
[vActionSheet setStyle1];
else if (_sgStyle.selectedSegmentIndex == 1)
[vActionSheet setStyle2];
else if (_sgStyle.selectedSegmentIndex == 2)
[vActionSheet setStyle3];

但是当我删除分段控件时,假设我选择 setStyle1 并执行:

DoActionSheet *vActionSheet = [[DoActionSheet alloc] init];
vActionSheet.nAnimationType = [vActionSheet setStyle1];

我在这里做错了什么?有没有更好的方法来解决这个问题?我集成了一个常规的 iOS UIActionSheet 就好了,我只是想要这个的外观。

最佳答案

我不是 100% 想要做什么,但是这段代码没有将 nAnimationType 设置为整数来改变它的动画。它只是调用返回 voidsetStyle1 方法。您将动画值与设置操作表外观的方法混淆了。

DoActionSheet *vActionSheet = [[DoActionSheet alloc] init];
vActionSheet.nAnimationType = [vActionSheet setStyle1];

你可能想要这样的东西:

DoActionSheet *vActionSheet = [[DoActionSheet alloc] init];
vActionSheet.nAnimationType = 0; // to use the normal animation or 1
vActionSheet.nAnimationType = 1; // to fade it in
vActionSheet.nAnimationType = 2; // 2 to bounce/pop it in

如果您想更改警报 View 按钮、背景等的外观...请在操作表实例上调用以下方法之一:

[vActionSheet setStyle1];
[vActionSheet setStyle2];
[vActionSheet setStyle3];

最后,演示项目不生成静态库或框架,因此在我看来,如果您要在项目中使用此类及其扩展,则需要所有源代码。集成您需要的位应该不难。

您需要做的就是在 Xcode 中创建一个名为“DoActionSheet”的新组,然后将 3rd Party Source 和 DoActionSheet 文件夹从演示项目的文件夹拖/放到您刚创建的新组中(从 Finder)。然后,您将获得头文件,就像它们在演示的 ViewController.m 中所做的那样。将其用作使用 DoActionSheet 类的指南。

关于ios - 自定义 UIActionSheet 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25334783/

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