숫자를 선택하는 작업 시트를 표시합니다. 하지만 지금은 액션 시트에 기본 선택된 버튼을 보여주고 싶습니다.표시하기 전에 Uiactionsheet 단추 텍스트와 배경을 변경하십시오.
코드 :
그들의 오류가 없지만 actionsheet가 표시되고 버튼 중 어느 것도 선택하지 :
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
for (UIView *subview in actionSheet.subviews) {
if ([subview isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)subview;
[button setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
if ([button.titleLabel.text isEqualToString:@"5"]) {
button.selected = true;
[button setBackgroundColor:[UIColor blueColor]];
}
}
}
}
편집을보기 전에
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Number"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil otherButtonTitles:@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10", nil];
[actionSheet showInView:self.view];
변경 버튼 텍스트와 배경.
당신의 오류가 무엇입니까? – Raptor
작업 시트에서 버튼을 선택하지 않았습니다. –