You have two options
Use
[alertView addSubview:[[UIButton alloc] init:...]]
Inherit a new view from UIAlertView and do it internally
If it is only shown in one spot, 1
is a quick and easy solution. You can setTag for each button and add the same click event
// Interface.h
NSArray *allButtons;
// Implementation.m
UIAlertView *alert = [[UIAlertView alloc] init:...];
UIButton *one = [UIButton buttonWithType:UIButtonTypeCustom];
UIButton *two = [UIButton buttonWithType:UIButtonTypeCustom];
...
// Load "empty star" and "filled star" images
UIImage *starUnselected = ...;
UIImage *starSelected = ...;
[one setImage:starUnselected forControlState:UIControlStateNormal];
[one setImage:starSelected forControlState:UIControlStateSelected];
// repeat for all buttons
...
[one setTag:1];
[two setTag:2];
...
[one addTarget:self action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];
// repeat for all buttons
allButtons = [NSArray arrayWithObjects:one, two, three, four, five];
// all buttons should subscribe
- (void)buttonPressed:(UIButton)sender
{
int tag = [sender getTag]; // The rating value
for (int i = 0; i < [allButtons length]; i++)
{
BOOL isSelected = i < tag;
[(UIButton)[allButtons objectAtIndex:i] setSelected:isSelected];
}
// Set alertTag to store current set one
// read [alert getTag] when OK button is pressed
[alert setTag:tag];
}