我想創建一個顯示一個UIActionSheet的功能,等到用戶按下一個按鈕,然後返回按鍵下壓如何要等到一個按鈕的代表被稱爲
@interface UIActionSheetHandler() <UIActionSheetDelegate>
@end
@implementation UIActionSheetHandler
-(NSInteger) buttonIndexWithMessage:(NSString *) title andArrayOfOptions:(NSArray *) options
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
for (NSString * strOption in options) {
[actionSheet addButtonWithTitle:strOption];
}
[actionSheet showInView:[BGMDApplicationsPointers window]];
//Wait till delegate is called.
return 0;//I want to return buttonIndex here.
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
//What should I put it here
}
@end
如何使//等到代表被呼叫等待?哦,我不想讓主線等待,但我想我可以解決這個問題。
爲什麼你想這樣做?按鈕索引將在按下按鈕時被傳遞 – giorashc 2013-03-12 10:16:06
因爲我已經有了一個等待按鈕索引的函數。用這種風格編程會更容易。 – 2013-03-12 11:50:48
介意如果我不同意:) ... – giorashc 2013-03-12 12:43:49