• 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: Simple NSView Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple NSView Question


  • Subject: Re: Simple NSView Question
  • From: Justin Giboney <email@hidden>
  • Date: Wed, 20 Aug 2008 11:06:02 -0600

I just noticed something.

If I put
NSLog(@"%@", [self subviews]);
into the drawRect: method, I get the following out put right after the app loads
2008-08-20 11:04:21.059 ViewApp[35666:10b] (
<NSTextField: 0x13b770>
)
2008-08-20 11:04:21.076 ViewApp[35666:10b] (
)


So it appears that the text field is getting removed immediately after it gets put in. Why is this?

Thanks,

Justin Giboney

On Aug 20, 2008, at 10:12 AM, Justin Giboney wrote:

I think that I am really close to this... but I can't find the next step.
I am trying to build a view programatically after the application has launched. So I have a custom view that has one method:


- (void)addLabelWithText:(NSString *)text
{
NSTextField *newTextField = [[NSTextField alloc] initWithFrame:NSMakeRect(5,5,17,50)];
[newTextField setStringValue:text];
[self addSubview: newTextField];
//[self setNeedsDisplay:YES];
}


If I add the code above into the drawRect: method, it works just fine. I think I need the commented line, but whether it is commented or not, it doesn't work. What do I have to do to redraw the view with the text field?

Thank you,

Justin Giboney
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Simple NSView Question (From: Justin Giboney <email@hidden>)

  • Prev by Date: mouseMoved events and unfocused views
  • Next by Date: Re: Right place to unobserve notifications in a document
  • Previous by thread: Simple NSView Question
  • Next by thread: Re: Simple NSView Question
  • Index(es):
    • Date
    • Thread