Search code examples
iosuiactionsheet

UIActionSheet customization using private API


I need to add images on action sheet buttons so I used following code

UIActionSheet *actionSheetObject = [[UIActionSheet alloc] initWithTitle:@"Follow Us" delegate:self cancelButtonTitle:kCancel destructiveButtonTitle:nil otherButtonTitles:@"Twitter",@"Facebook",@"Blog",@"LinkedIn",nil];
[[[actionSheetObject valueForKey:@"_buttons"] objectAtIndex:0] setImage:[UIImage imageFromBundle:@"TwitterIcon"] forState:UIControlStateNormal];
[[[actionSheetObject valueForKey:@"_buttons"] objectAtIndex:1] setImage:[UIImage imageFromBundle:@"FacebookIcon"] forState:UIControlStateNormal];
[[[actionSheetObject valueForKey:@"_buttons"] objectAtIndex:2] setImage:[UIImage imageFromBundle:@"BlogIcon"] forState:UIControlStateNormal];
[[[actionSheetObject valueForKey:@"_buttons"] objectAtIndex:3] setImage:[UIImage imageFromBundle:@"LinkedInIcon"] forState:UIControlStateNormal];
[actionSheetObject showInView:self.view];

OutPut enter image description here

But My question is it the correct way to achieve this? Means Apple will accept my app on appstore?


Solution

  • 99.9% is that Apple will accept this, because compiler will not detect no warnings about this, but there is other problem, Apple can change the name of variables in the UIActionSheet, I mean, this code is risky, but definitely will work and pass the Apple validations.