Один из способов заключался бы в инкапсуляции вашей таблицы действий + делегата в новый класс:
@interface MyActionSheet : NSObject <UIActionSheetDelegate>
{
UIActionSheet* _actionSheet;
}
@end
@implementation MyActionSheet
- (id) initAndShowInView: (UIView*) view
{
if ( (self = [super init] ) )
{
_actionSheet = [[UIActionSheet alloc] initWithTitle: @"Hi There" delegate:self cancelButtonTitle:@"done" destructiveButtonTitle: nil otherButtonTitles: @"button 1", @"button2", nil];
[_actionSheet showInView:view];
}
return self;
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
// your logic here
}
- (void)dealloc {
[_actionSheet release];
[super dealloc];
}
@end
Это можно расширить, добавив методы делегирования, которые могут вам понадобиться. Вам нужно будет убедиться, что объект продолжает жить (сохраните его), пока лист действий является видимым - лист действий не увеличивает счетчик ссылок для своего делегата ...