• 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: Weird behavior when adding subview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird behavior when adding subview


  • Subject: Re: Weird behavior when adding subview
  • From: August Trometer <email@hidden>
  • Date: Thu, 20 Apr 2006 19:04:33 -0400


You probably shouldn't be adding subviews in drawRect: because it gets called quite frequently. In your case, every time drawRect: gets called, another NSTextField gets added. What you're seeing is many of your NSTextFields, all drawn over the top of each other. Your custom view then has multiple subviews, only one of which you really intend. I'd find a different place to add the subview.


-- August




On Apr 20, 2006, at 6:25 PM, Eamon Ford wrote:

I have a custom view in which I programmatically create an NSTextField and add it as a subview, in the drawRect: method. But whenever the view is redrawn (i.e. I resize the window, etc.), it seems to redraw the text field over itself. Sorry, I couldn't think of a better explanation, but here's a screenshot of what's happening: <http://homepage.mac.com/eamonford/screenshot.png>

I'm sure there's a simple solution, but I'm not very experienced. What would be the best way to fix this?


Thanks.


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev 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. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Weird behavior when adding subview (From: Eamon Ford <email@hidden>)

  • Prev by Date: Re: Should I use Core Data?
  • Next by Date: Re: Should I use Core Data?
  • Previous by thread: Weird behavior when adding subview
  • Next by thread: Re: Weird behavior when adding subview
  • Index(es):
    • Date
    • Thread