排队的 ViewControllers 被一个接一个地推送
Queuing ViewControllers to be Pushed One By One
我们如何"queue" ViewControllers 被一个一个推送?
我的应用程序检查 "Friend Requests" 的数量,我想一个接一个地推送。
Check for Requests
Found 3 Requests
Push FriendRequestViewController
User Press OK
Push Another FriendRequestViewController
User Press OK
Push Another FriendRequestViewController
Done
我试过使用循环,但它只会立即从 currentViewController 中推送三个视图控制器。
for request in friendRequests
{
let friendRequestViewController = FriendRequestViewController();
friendRequestViewController.request = request;
self.navigationController.presentViewController(friendRequestViewController);
}
有什么想法吗?谢谢
我能想到声明协议之类的东西
protocol FriendRequestControllerDelegate {
func friendRequestContollerConfirmed(friendRequestController : FriendRequestViewController)
}
然后,在提交好友请求的对象中
//somewhere you have requestsEnumerator
func friendRequestContollerConfirmed(friendRequestController : FriendRequestViewController) {
request = requestsEnumerator.nextObject();
if request {
let friendRequestViewController = FriendRequestViewController();
friendRequestViewController.request = request;
friendRequestViewController.delegate = self;
self.navigationController.presentViewController(friendRequestViewController);
}
}
在你第一次提交好友请求的地方调用这个函数
在 FriendRequestController 中使自己成为您的“确定”按钮的目标。
func okButtonTapped() {
if(self.delegate.respondsToSelector:Selector(friendRequestContollerConfirmed)) {
self.delegate.friendRequestContollerConfirmed(self)
}
}
我们如何"queue" ViewControllers 被一个一个推送?
我的应用程序检查 "Friend Requests" 的数量,我想一个接一个地推送。
Check for Requests
Found 3 Requests
Push FriendRequestViewController
User Press OK
Push Another FriendRequestViewController
User Press OK
Push Another FriendRequestViewController
Done
我试过使用循环,但它只会立即从 currentViewController 中推送三个视图控制器。
for request in friendRequests
{
let friendRequestViewController = FriendRequestViewController();
friendRequestViewController.request = request;
self.navigationController.presentViewController(friendRequestViewController);
}
有什么想法吗?谢谢
我能想到声明协议之类的东西
protocol FriendRequestControllerDelegate {
func friendRequestContollerConfirmed(friendRequestController : FriendRequestViewController)
}
然后,在提交好友请求的对象中
//somewhere you have requestsEnumerator
func friendRequestContollerConfirmed(friendRequestController : FriendRequestViewController) {
request = requestsEnumerator.nextObject();
if request {
let friendRequestViewController = FriendRequestViewController();
friendRequestViewController.request = request;
friendRequestViewController.delegate = self;
self.navigationController.presentViewController(friendRequestViewController);
}
}
在你第一次提交好友请求的地方调用这个函数
在 FriendRequestController 中使自己成为您的“确定”按钮的目标。
func okButtonTapped() {
if(self.delegate.respondsToSelector:Selector(friendRequestContollerConfirmed)) {
self.delegate.friendRequestContollerConfirmed(self)
}
}