In my iOS 8 application I am using UIActionSheet. I tried to change the color of the button title in willPresentActionSheet
delegate method, but it is not recognizing buttons as its subview.
I constructed UIActionSheet
like this:
UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Select an Option" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles: nil];
popup.tag = 2;
[popup addButtonWithTitle:@"Add Tag To Chat"];
[popup addButtonWithTitle:@"Remove Tag From Chat"];
[popup addButtonWithTitle:@"Terminate"];
[popup addButtonWithTitle:@"Cancel"];
[popup showInView:self.view];
Delegate is:
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
NSLog(@"%d",[actionSheet.subviews count]);
for (UIView *subview in actionSheet.subviews) {
if ([subview isKindOfClass:[UIButton class]]) {
UIButton *button = (UIButton *)subview;
[button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
}
}
}
Buttons are showing, I can click and action performs. But it says count = 0. Why?