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 346799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:12:40+00:00 2026-05-12T11:12:40+00:00

Is there a built-in way to get from a UIView to its UIViewController ?

  • 0

Is there a built-in way to get from a UIView to its UIViewController? I know you can get from UIViewController to its UIView via [self view] but I was wondering if there is a reverse reference?

  • 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-12T11:12:40+00:00Added an answer on May 12, 2026 at 11:12 am

    Since this has been the accepted answer for a long time, I feel I need to rectify it with a better answer.

    Some comments on the need:

    • Your view should not need to access the view controller directly.
    • The view should instead be independent of the view controller, and be able to work in different contexts.
    • Should you need the view to interface in a way with the view controller, the recommended way, and what Apple does across Cocoa is to use the delegate pattern.

    An example of how to implement it follows:

    @protocol MyViewDelegate < NSObject >
    
    - (void)viewActionHappened;
    
    @end
    
    @interface MyView : UIView
    
    @property (nonatomic, assign) MyViewDelegate delegate;
    
    @end
    
    @interface MyViewController < MyViewDelegate >
    
    @end
    

    The view interfaces with its delegate (as UITableView does, for instance) and it doesn’t care if its implemented in the view controller or in any other class that you end up using.

    My original answer follows: I don’t recommend this, neither the rest of the answers where direct access to the view controller is achieved

    There is no built-in way to do it. While you can get around it by adding a IBOutlet on the UIView and connecting these in Interface Builder, this is not recommended. The view should not know about the view controller. Instead, you should do as @Phil M suggests and create a protocol to be used as the delegate.

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

Sidebar

Related Questions

Is there any built in method to get which can parse int from string
Is there a way to get emails from built-in Android email application. If so,
Is there a way to get the built-in Everyone registry security object in a
Is there a built in way to convert an integer in Ruby into its
Is there a built-in way to know if a given session variable is a
Is there any built in way to get a users email address based on
Is there any way to get the byte values from the strings returned from
I find myself wondering if there's a built-in Ruby method to get the nth
Is there an stl way to get a list of values from a map?
Is there a way to get struts 2 (using tiles) to build the whole

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.