If you are thinking to add multiple buttons in a alert view in IOS , Its very simple now.
you need to do few lines of code.
please take a look at the below lines of code.
@interface YourViewController : UIViewController
- (IBAction)YourButtonAction:(id)sender
{
UIButton *TickButton=(UIButton *)sender;
NSMutableArray *myArray1 = [[NSMutableArray alloc] initWithObjects:@“Title1”,@“Title2”, @"Title3”, @"Title4”,@“Title5”,@“Title6”, nil];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
message:nil delegate:self
cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
alertView.alertViewStyle = UIAlertViewStyleDefault;
for(NSString *buttonTitle in myArray1)
{
[alertView addButtonWithTitle:buttonTitle];
}
[alertView show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Title1"])
{
// write your code here
}
else if([title isEqualToString:@"Title2”])
{
// write your code here
}
else if([title isEqualToString:@"Title3”])
{
// write your code here
}
else if([title isEqualToString:@"Title4”])
{
// write your code here
}
}
Discover more from mycodetips
Subscribe to get the latest posts sent to your email.