0
是有我們的方式來阻止一個for循環?封閉循環中使用UIAlertController
我有一個循環,在它裏面,它向用戶提供一個對話框。我希望它在用戶按下確定或取消後暫停循環。
可能嗎?
因爲循環alertController看起來非常難看,特別是當你有很多循環。
for request in friendRequests
{
let alertController = UIAlertController(title: "Friend Request", message: "Would you like to accept this friend request?", preferredStyle: UIAlertControllerStyle.Alert);
let cancelAction: UIAlertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Cancel, handler: nil);
let confirmAction: UIAlertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil);
alertController.addAction(cancelAction);
alertController.addAction(confirmAction);
//How do we block or wait until user press a button??
self.navigationController.presentViewController(alertController);
}
有什麼想法?由於