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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:31:05+00:00 2026-06-17T07:31:05+00:00

Is it possible in Cocoa to add component on view programatically? The UI is

  • 0

Is it possible in Cocoa to add component on view programatically? The UI is created using the Interface Builder from Xcode. I just want to add some NSButtons but its quantity and positions will be known at the runtime and user input.

Does anyone knows is it possible and how it could be done and how positioning these ynamic components?

  • 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-06-17T07:31:06+00:00Added an answer on June 17, 2026 at 7:31 am

    Of course it is possible.
    Adding a subview:

    UIView *subview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]; // or UIButton, UIScrollView, or any other view-based class you make think of
    [self addSubview:subview];
    

    etc.

    Or to be more precise for a button it would be something like this:

    UIButton *aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    aButton.frame = CGRectMake(0, 0, 100, 100);
    [aButton addTarget:self action:@selector(methodName) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:aButton]; // if done from the view self.view if done from the controller
    

    Ah, sorry just noticed it was OSX, not iOS, but the basics are the same. Have a look at the NSButton class instead.

    NSButton *aButton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; // x, y, width, height
    

    should get you started.

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

Sidebar

Related Questions

Is it possible to add events to iCal from my cocoa app? I tried
Possible Duplicate: Calling Python from Objective-C I'm a long-time Python programmer and short-time Cocoa
would it be possible to bind a Java application to a Cocoa graphical interface?
I would like to add notification center from a cpp class, is it possible????
Is it possible to hide one specific application using cocoa? I know you can
Possible Duplicate: How to get pixel data from a UIImage (Cocoa Touch) or CGImage
Is it possible to send keystrokes to a cocoa app? I don't want to
Possible Duplicate: Parsing XML in Cocoa iPhone - Can we parse .plist(xml) file using
Is it possible to log the current line number using NSLog in Cocoa /
Is it possible to make a Cocoa app scriptable using Ruby instead of AppleScript?

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.