gpt4 book ai didi

iphone - UIActionSheet 按钮索引

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:04:42 25 4
gpt4 key购买 nike

我的应用中有一个 UIActionSheet,默认有 4 个按钮。如果用户自定义图像,操作表会获得额外的第 5 个按钮,允许用户重置此图像。

我正在使用此委托(delegate)方法来确定单击了哪个操作表按钮:

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 

问题是默认情况下,取消按钮位于 buttonIndex 2,但当出现第 5 个按钮时,它位于 buttonIndex 3。无论如何,通过了解 buttonIndex,您是否可以访问操作表按钮的标题/名称?

最佳答案

是的,您可以使用以下方法向操作表询问给定索引处的按钮标题:

-(NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;

或者,UIActionSheet 定义一个属性:

@property(nonatomic) NSInteger cancelButtonIndex;

关于iphone - UIActionSheet 按钮索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8892803/

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