1

In UIAlertView, how can I place a lot of buttons inside it? I've got an alert view and want to place ten buttons inside of it, but when in place, then they don't fit in the screen? Moreover, how should I make the buttons look a little bit different, and how can I change their sizes?

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Фильтр по категориям" message:@"Выбирите категорию:" delegate:self cancelButtonTitle:@"Отменить" 
                                          otherButtonTitles:@"Все", @"Избранное", @"Тосты", @"Рассказы", @"Стихи", @"Анекдоты", @"Афоризмы", @"Объявления", @"Разное", nil];

In English:

UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "Filter by Category" message: @ "Choose a category:" delegate: self cancelButtonTitle: @ "Cancel"
                                       otherButtonTitles: @ "All", @ "Music", @ "Toast", @ "Stories", @ "Poems", @ "Jokes", @ "Aphorisms", @ "Announcements", @ "Other", nil];
mackworth
  • 5,873
  • 2
  • 29
  • 49
Vladimir Stazhilov
  • 1,956
  • 4
  • 31
  • 63

3 Answers3

3

You should not place ten buttons inside a UIAlertView.

I don't know Russian so I have no clue as to the context of your problem. But there's no reason to put that many choices in an alert view.

lorean
  • 2,150
  • 19
  • 25
3

Lorean is correct.

On the iPhone, for selecting a category filter, you should use a modal ViewController (with presentModalViewController), which will roll over your main view, allow them to select their category and then disappear.

On the iPad, you should use a UIPopoverController.

mackworth
  • 5,873
  • 2
  • 29
  • 49
  • To quote Apple's HIG: Generally, use a two-button alert. A two-button alert is often the most useful, because it is easiest for people to choose between two alternatives. ... An alert that contains three or more buttons is significantly more complex than a two-button alert and should be avoided if possible. In fact, if you find that you need to offer people more than two choices, you should consider using an action sheet instead. – mackworth Sep 26 '11 at 16:52
  • Since you want a look that UIAlertView doesn’t provide, that alone says you should not use it. – David Dunham Sep 26 '11 at 17:51
1

You might want to look on alternative alert view implementations https://github.com/TomSwift/TSAlertView

But be honest to yourself, if so many buttons make sense on a alert view. You also can use presentModalViewController to present a custom view, where you have all flexibility.

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178