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

Change unbutton title from u inactionsheet button

我有一个显示 uiactionsheet 的 uibutton。我想用 uiactionsheet 按钮标题替换取消按钮标题。 uiactionsheet 按钮显示无线电波段 (AM/FM) 选择。 uiactionsheet 将 select 乐队。然后我希望 uibutton 标题显示 selected 的模式。 "clickedButtonAtIndex" 在动作 sheet actions.

中添加什么
            - (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: 但首先检查按下的按钮不是取消按钮。