ios - 从你的 inactionsheet 按钮更改取消按钮标题

标签 ios uibutton uiactionsheet

我有一个显示 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/

相关文章:

ios - 如何在 Realm 中使用随机和限制

ios - 数据未显示在 firebase 数据库中

ios - 在左侧对齐 UIButton 的图像和 UILabel

ios - 在 iOS8 中显示带有 UIActionSheet 的 UIPickerView 不起作用

ios - 横向 View 的媒体查询

ios - Callkit CXHandle .generic 类型问题

ios - Swift 左侧仅带边框的圆形按钮

iphone - 用于调用的 iOS 原生 iPhone 按钮

iPhone UIActionSheet

iOS : sms message composer not showing