如何讓我的委託方法等待,直到用戶對alertview確認做出選擇?阻止執行,直到確認AlertView被用戶解僱,並返回結果
BOOL userChoice = FALSE;
我有這樣的委託方法:
-(BOOL) returnUserChoiceYESorNO:(NSString*)message { //delegate method
UIAlertView *msgBox = [[UIAlertView alloc] initWithTitle:@"Your Choice" message:message delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil];
[msgBox show];
[msgBox release];
//// HOW CAN I MAKE IT WAIT HERE, UNTIL I RECEIVE USER Responce from ClickedButtonAtIndex? (without using while loop or infinite loops)
return userChoice;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex==0) {
userChoice = NO;
else
{
userChoice = YES;
}
}
這是一個DELEGATE方法。一旦呼叫,我們需要立即迴應。 – RealHIFIDude 2009-08-11 00:02:45