On Wednesday, July 18, 2012 12:46:16 PM UTC-5, oster wrote:
> Where the sample app calls:
> [[self navigationController] pushViewController:viewController
> animated:YES];
> instead call:
> MyNavigationController *presentModal = [[[MyNavigationController alloc]
> initWithRootViewController:viewController] autorelease];
> [presentModal setDismisser:self];
> UIBarButtonItem *cancelButton = [[[UIBarButtonItem alloc]
> initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self
> action:@selector(doDismiss)] autorelease];
> [[viewController navigationItem] setLeftBarButtonItem:cancelButton];
> [[self navigationController] presentModalViewController:presentModal
> animated:YES];
> where doDismiss is:
> - (void)doDismiss {
> [self dismissModalViewControllerAnimated:YES];
> }
> that handles showing and canceling.
> For auto-dismiss, we catch the pop that the OAuth2ViewController will do:
> @interface MyNavigationController : UINavigationController
> @property (nonatomic, assign) UIViewController *dismisser;
> - (UIViewController *)popViewControllerAnimated:(BOOL)animated;
> @end
> @implementation MyNavigationController
> @synthesize dismisser;
> - (UIViewController *)popViewControllerAnimated:(BOOL)animated {
> if ([[self viewControllers] count] <= 1) {
> UIViewController *result = [[[self topViewController] retain]
> autorelease];
> [dismisser dismissModalViewControllerAnimated:YES];
> return result;
> } else {
> return [super popViewControllerAnimated:animated];
> }
> }
> @end
> Warning: I didn't actually try the auto-dismiss case.
> On Wed, Jul 18, 2012 at 4:39 AM, Zak <zakd...@gmail.com <javascript:>>wrote:
>> How can I adapt or subclass GTMOAuth2ViewControllerTouch to use as a
>> modal view? Currently I have it opening ok, but it fails at a few key
>> places (for example, it doesn't auto-close when it reaches the
>> authorization success page.). What steps do I need to take to make it work
>> as a modal view?