If not simply instantiate it and assign it. Expanding on what I said before, I'm not sure what you're trying to do but taking a look at your code you are creating the view for a brief moment when the notification gets called and right there it's getting deallocated because no one is holding a reference to it. The other option you have if you're not using interface builder to set everything up is the following in your viewDidLoad :.
As a final note, considering you're new to iOS development as we all were you can go to iTunes and look for Stanford's iPad and iPhone Development course CSP on iTunes U, it's completely free and it will teach you most of what you need to know for developing in iOS. Get answers to millions of questions and give back by sharing your knowledge with others.
This normally happens as part of the event loop, if anything has marked the view as needing display. So, if you need to do something to it before it gets told to, either do it immediately after creating it or, if you're about to set the view as needing display, do it before you do that.
I just created my first customView app. This was one of my questions. And millions of time when resizing my window. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. When is 'drawRect' called? Ask Question. Asked 11 years, 8 months ago. Active 11 years, 8 months ago. Was this page useful? Let us know! You are not logged in Log in or create account. Link copied to your pasteboard. If I implement drawLayer:inContext: , it is called and drawRect isn't, at least as far as putting a breakpoint can tell , even if I don't assign my view as the CALayer delegate by using:.
That's why [[self layer] setDelegate:self]; seemed to do nothing. It's redundant. The drawRect: method is effectively the drawing delegate method for the view's layer. You can see it in the debugger:. This is why drawRect: was never called when you implemented drawLayer:inContext:. You should also never make any view the drawing delegate for another layer. That will cause all sorts of wackiness. If I understand you right you can write a value successfully to a characteristic but you don't get a pairing request.
0コメント