Я сделал что-то подобное, чтобы настроить лист действий:
- (void) showPopup {
unitPicker * pc = [[unitPicker alloc] init];
UIActionSheet * popupQuery = [[UIActionSheet alloc]
initWithTitle: @ "Единицы измерения"
Делегат: шт
cancelButtonTitle: ноль
destructiveButtonTitle: ноль
otherButtonTitles: ноль
];
[pc setParent:self];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[popupQuery showInView:self.view];
[popupQuery setBounds:CGRectMake(0,0,320, 350)];
[pc setAs:popupQuery];
[popupQuery addSubview:pc.view];
}
Хитрость заключается в том, что unitPicker был получен из UIControllerView, но реализовал протокол UIActionSheetDelegate. Он снабжен двумя функциями:
- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex;
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex;
Чтобы справиться с любой очисткой. Большая часть состояла в том, что формат unitPicker был создан из NIB, как это было бы с любым UIViewController.
Кнопки в представлении закрывали actionSheet с кодом в их обработчиках touchUpInside:
[as dismissWithClickedButtonIndex:0 animated:TRUE];
(Вы можете видеть в приведенном выше коде, что «as» был задан как объект actionSheet).