Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6657751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:48:32+00:00 2026-05-26T01:48:32+00:00

I have a custom UIButton class in my IPhone navigation application. When the user

  • 0

I have a custom UIButton class in my IPhone navigation application. When the user clicks the button I present a modal view which displays a tableview list of records that the user can select from.

On click of the button I create my viewController and show it using the following code:

-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    dropDownPickerViewController = [[DropDownListingViewController alloc] initWithNibName:@"DropDownListingView" bundle:[NSBundle mainBundle]];
    .....
    .....

[[(AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate] navigationController] presentModalViewController:dropDownPickerViewController animated:NO];
[dropDownPickerViewController release];

[super touchesEnded:touches withEvent:event];
}

As you can see the button could be on any viewController so I grab the navigationController from the app delegate. Than in my DropDownPickerViewController code i have the following when a user selects a record:

[[(AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate] navigationController] dismissModalViewControllerAnimated:NO];

But nothing occurs. It seems to freeze and hang and not allow any interaction with the form. Any ideas on why my ModalViewController wouldnt be dismissing? Im thinking it is the way I use the app delegate to present the viewController. Is there a way to go self.ParentViewController in a UIButton class so I can get the ViewController of the view that the button is in (if this is the problem)?

Any ideas would be greatly appreciated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:48:32+00:00Added an answer on May 26, 2026 at 1:48 am

    I did recall that I did have to do something similar once, and by looking at this post:

    Get to UIViewController from UIView?

    I was able to create some categories:

    //
    //  UIKitCategories.h
    //
    
    #import <Foundation/Foundation.h>
    
    @interface UIView (FindUIViewController)
    - (UIViewController *) firstAvailableUIViewController;
    - (id) traverseResponderChainForUIViewController;
    @end
    
    @interface UIView (FindUINavigationController)
    - (UINavigationController *) firstAvailableUINavigationController;
    - (id) traverseResponderChainForUINavigationController;
    @end
    
    
    
    
    //
    //  UIKitCategories.m
    //
    
    #import "UIKitCategories.h"
    
    @implementation UIView (FindUIViewController)
    - (UIViewController *) firstAvailableUIViewController {
        // convenience function for casting and to "mask" the recursive function
        return (UIViewController *)[self traverseResponderChainForUIViewController];
    }
    
    - (id) traverseResponderChainForUIViewController {
        id nextResponder = [self nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return nextResponder;
        } else if ([nextResponder isKindOfClass:[UIView class]]) {
            return [nextResponder traverseResponderChainForUIViewController];
        } else {
            return nil;
        }
    }
    
    @end
    
    @implementation UIView (FindUINavigationController)
    - (UINavigationController *) firstAvailableUINavigationController {
        // convenience function for casting and to "mask" the recursive function
        return (UINavigationController *)[self traverseResponderChainForUINavigationController];
    }
    
    - (id) traverseResponderChainForUINavigationController {
        id nextResponder = [self nextResponder];
        if ([nextResponder isKindOfClass:[UINavigationController class]]) {
            return nextResponder;
        } else {
            if ([nextResponder isKindOfClass:[UIViewController class]]) {
                //NSLog(@" this is a UIViewController ");
                return [nextResponder traverseResponderChainForUINavigationController];
            } else {
                if ([nextResponder isKindOfClass:[UIView class]]) {
                    return [nextResponder traverseResponderChainForUINavigationController];
                } else {
                    return nil;
                }
            }
        }
    }
    
    @end
    

    you can then call them like so:

    UINavigationController *myNavController = [self firstAvailableUINavigationController];
    
    UIViewController *myViewController = [self firstAvailableUIViewController];
    

    maybe they will help you, I hope so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive got an iPhone/iPad universal application and I wanted to have a custom navigation
I have created a custom button called ModuleUIButton which inherits from UIButton . This
I have a custom UIButton that has the label Name. When the user clicks
I have an iPhone UIButton (Custom) which has a background image and text. When
I have a custom UITableViewCell which contains several UIButtons. Each button's frame position is
I have a custom button, subclassed from UIButton that is initialised as below (obviously
I have a mapkit application, where I've created a custom callout view. I can't
In IB I have a view with a UIButton of Type Custom, it has
I have a simple (view-based) application. I want on tapping on custom UIView my
I have some animation attached to a custom button in a view controller: -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.