If the number of topics is less than or equal to six, you can use the UIActionSheet with several buttons. In your view of the controller, click on the "Select Theme" button with the following code:
UIActionSheet* as = [[UIActionSheet alloc] initWithTitle:@"Choose Theme" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Theme 1", @"Theme 2", @"Blue Theme", @"etc."]; [as showInView:[self view]];
At the top of your .h file, next to the class definition, add the following:
<UIActionSheetDelegate>
And the .m file declaration uses the following method:
-(void)actionSheet:(UIActionSheet*)as clickedButtonAtIndex:(NSInteger)index { switch(index) { case 0: //It was theme 1 break; case 1: //It was Theme 2 break; case 3: //It was blue theme break; //And so on... } }
Replace comments by switching to the selected topic.
Note: if you have more than six topics, you need something more like the solution discussed in this . Question about UIPickerViews in action sheets.
source share