• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Positioning Controls
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Positioning Controls


  • Subject: Re: Positioning Controls
  • From: Lee Ann Rucker <email@hidden>
  • Date: Thu, 18 Apr 2013 11:01:54 -0700 (PDT)
  • Thread-topic: Positioning Controls

The "Button Madness" sample app demonstrates making buttons in both code and nibs. OSX, but easily ported.

----- Original Message -----
From: "Scott Ribe" <email@hidden>
To: "Harmony Neil" <email@hidden>
Cc: email@hidden
Sent: Thursday, April 18, 2013 9:27:52 AM
Subject: Re: Positioning Controls

On Apr 18, 2013, at 9:39 AM, Harmony Neil wrote:

> It would make things a whole lot easier if you could just do stuff by nice old writing the code, but alas no ...

You can actually do this. Although the whole paradigm that Apple's dev tools support promote doing it the visual way, in your case it might well make sense to create the control, place and position it in its superview, connect it to the controller's outlet, and set its action & target in code.

I've never needed to do this, so I can't give you complete step-by-step instructions, but I can give you a (possibly incomplete) guide to the methods you need:

--------------------------------------------------------------

myButton = [[[NSButton alloc] initWithFrame: ...] autorelease]

configure it, see the "Configuring Buttons" section of the NSButton Class Reference

[myButton setTarget: myController]
[myButton setAction: @selector(myActionMethod:)]

[[[myController window] contentView] addSubview: myButton]

myController->myButton = myButton

--------------------------------------------------------------

Note that you can use similar techniques to create a window and an instance of your controller and associate them, you'll want the "Creating Windows" section of the NSWindow Class Reference, and the initWithWindow: method of NSWindowController

--
Scott Ribe
email@hidden
http://www.elevated-dev.com/
(303) 722-0567 voice





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Positioning Controls (From: Harmony Neil <email@hidden>)
 >Re: Positioning Controls (From: Scott Ribe <email@hidden>)

  • Prev by Date: Re: Positioning Controls
  • Next by Date: Re: Positioning Controls
  • Previous by thread: Re: Positioning Controls
  • Next by thread: Re: Positioning Controls
  • Index(es):
    • Date
    • Thread