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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:26:11+00:00 2026-05-27T16:26:11+00:00

In many iOS books and tutorials they demonstrate how in interface builder you can

  • 0

In many iOS books and tutorials they demonstrate how in interface builder you can basically turn a UIView into a UIControl and have it inherit new higher level functionality to respond to clicks and behave like button for example. This is done simply by changing the class type in interface builder of a selected UIView.

This is often done to dismiss the keyboard when someone touches on the “background” or main view of a given view controller. Once a UIView’s class is changed to a UIControl you just assign connect a new IBAction for when a TouchUpInside event occurs for example.

Now I understand this concept but it seams like a weird Xcode hack. The reason is, I don’t see how I could accomplish the same thing programatically. Let me explain: If I create an instance of a UIView in code and I want it to behave like a UIControl how would I tell this UIView instance that I want it to inherit from UIControl. Now keep in mind I don’t actually want to subclass UIControl because that would be jumping through more hoops and I don’t think that is what Interface Builder is doing when you change that class type, or is it? Also, keep in mind UIControl is meant to be an abstract class and not to be used directly otherwise I would probably just do that.

Ultimately my question is, is there an equivalent way to accomplish the same thing in pure code and have a UIView become a UIControl such that I can assign the higher level events to it?

I hope this makes sense, if not I can elaborate.

  • 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-27T16:26:12+00:00Added an answer on May 27, 2026 at 4:26 pm

    UIControl inherits from UIView, so if you wanted to do this programmatically, you would just create an instance of UIControl instead. So if you were creating a view controller’s view programmatically, for instance, you could do something like:

    - (void)loadView
    {
      CGRect viewSize = /* some appropriate default size */
      UIControl* myControlView = [[UIControl alloc] initWithFrame:viewSize];
      // configure your control (e.g., set events, etc)
      [self setView:myControlView];
      [myControlView release]; // omit this line if using ARC
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iOS app where you can drag many images and rotate them.
I've reviewed many websites and youtube videos that have IOS 5 storyboarding information. Most
I've read and watched many tutorials on NSUserDefaults in the iPhone OS/iOS SDK, but
Many iOS developers have found the Cocoa Lumberjack Logging framework to fill a need
It had many iOS ui elements programmed into it for use like table views
I'm currently writing an iOS app and I have many records that I'm writing
I have many view controllers on my iOS app and in most of them
My company has an iOS developer license, and like many others we have reached
I'm a bit confused. It says on many places, that on IOS you can't
Many times I have seen Visual Studio solutions which have multiple projects that share

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.