我有一个显示 uiactionsheet 的 uibutton。我想用 uiactionsheet 按钮标题替换取消按钮标题。 uiactionsheet 按钮显示 radio 波段 (AM/FM) 选择。 uiactionsheet 将选择波段。然后我希望 uibutton 标题显示选择了哪种模式。 我要在操作表操作中添加什么“clickedButtonAtIndex”。
- (IBAction)modeButton1:(id)sender
{
UIActionSheet *actionSheet2 = [[UIActionSheet alloc] initWithTitle:@"Mode Select"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"FM",@"AM",nil];
[actionSheet2 showFromRect:[(UIButton *)sender frame] inView:self.view animated:YES];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
NSLog(@"FM mode selected");
}
else if (buttonIndex == 1)
{
NSLog(@"AM mode selected");
}
}
最佳答案
为按钮创建一个属性并在 clickedButton 中使用 setTitle:ForState:
但首先检查按下的按钮不是取消按钮。
关于ios - 从你的 inactionsheet 按钮更改取消按钮标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28349205/