dismissWithCompletion
This commit is contained in:
parent
123bf96609
commit
4100525890
|
@ -256,7 +256,7 @@ class CheckoutViewController: UIViewController, STPPaymentContextDelegate, STPSh
|
|||
else {
|
||||
self.shippingRow.detail = "Enter \(self.shippingString) Info"
|
||||
}
|
||||
self.shippingVC.dismiss(withHostViewController: self)
|
||||
self.shippingVC.dismiss(completion: nil)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,6 +53,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*/
|
||||
@property(nonatomic)STPUserInformation *prefilledInformation;
|
||||
|
||||
/**
|
||||
* If you're pushing `STPPaymentMethodsViewController` onto an existing `UINavigationController`'s stack, you should use this method to dismiss it, since it may have pushed an additional add card view controller onto the navigation controller's stack.
|
||||
*
|
||||
* @param completion The callback to run after the view controller is dismissed. You may specify nil for this parameter.
|
||||
*/
|
||||
- (void)dismissWithCompletion:(nullable STPVoidBlock)completion;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,9 +47,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
/**
|
||||
* If you're pushing `STPShippingAddressViewController` onto an existing `UINavigationController`'s stack, you should use this method to dismiss it, since it may have pushed an additional shipping method view controller onto the navigation controller's stack.
|
||||
*
|
||||
* @param hostViewController the view controller that the shipping address view controller was pushed onto.
|
||||
* @param completion The callback to run after the view controller is dismissed. You may specify nil for this parameter.
|
||||
*/
|
||||
- (void)dismissWithHostViewController:(UIViewController *)hostViewController;
|
||||
- (void)dismissWithCompletion:(nullable STPVoidBlock)completion;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#import "STPWeakStrongMacros.h"
|
||||
#import "STPLocalizationUtils.h"
|
||||
#import "STPDispatchFunctions.h"
|
||||
#import "UINavigationController+Stripe_Completion.h"
|
||||
|
||||
@interface STPPaymentMethodsViewController()<STPPaymentMethodsInternalViewControllerDelegate, STPAddCardViewControllerDelegate>
|
||||
|
||||
|
@ -210,6 +211,22 @@
|
|||
[self internalViewControllerDidCreateToken:token completion:completion];
|
||||
}
|
||||
|
||||
- (void)dismissWithCompletion:(STPVoidBlock)completion {
|
||||
if ([self stp_isAtRootOfNavigationController]) {
|
||||
[self.presentingViewController dismissViewControllerAnimated:YES completion:completion];
|
||||
}
|
||||
else {
|
||||
UIViewController *previous = self.navigationController.viewControllers.firstObject;
|
||||
for (UIViewController *viewController in self.navigationController.viewControllers) {
|
||||
if (viewController == self) {
|
||||
break;
|
||||
}
|
||||
previous = viewController;
|
||||
}
|
||||
[self.navigationController stp_popToViewController:previous animated:YES completion:completion];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation STPPaymentMethodsViewController (Private)
|
||||
|
|
|
@ -263,8 +263,20 @@
|
|||
[self presentViewController:alertController animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)dismissWithHostViewController:(UIViewController *)hostViewController {
|
||||
[self.navigationController stp_popToViewController:hostViewController animated:YES completion:nil];
|
||||
- (void)dismissWithCompletion:(STPVoidBlock)completion {
|
||||
if ([self stp_isAtRootOfNavigationController]) {
|
||||
[self.presentingViewController dismissViewControllerAnimated:YES completion:completion];
|
||||
}
|
||||
else {
|
||||
UIViewController *previous = self.navigationController.viewControllers.firstObject;
|
||||
for (UIViewController *viewController in self.navigationController.viewControllers) {
|
||||
if (viewController == self) {
|
||||
break;
|
||||
}
|
||||
previous = viewController;
|
||||
}
|
||||
[self.navigationController stp_popToViewController:previous animated:YES completion:completion];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - STPAddressViewModelDelegate
|
||||
|
|
Loading…
Reference in New Issue