objective c - iOS drawing context NULL in gesture handler -


I am having difficulty in attracting iOS in response to gesture events, and I'm sure this is because I Perhaps some non-obvious fundamental iOS programming concepts have been lost. Anyway, it seems that when code is executed in response to an event, UIGraphicsGetCurrentContext () taps me, I do not understand why other drawing code in the view method of the view, just fine Does.

I can see that the events are being removed as I am logging in. UIGraphicsGet taps the currentContext when executing inside the event handling code (even when it is in the code view function that sets event handling?

Additionally, this error is logged:

error>: CGContextSetFillColorWithColor: invalid reference 0x0. This is a serious error. This application, or uses a library, is using an invalid reference and System Stability And the overall level of reliability contributes to the decline. This notice is a courtesy: Please fix this problem. This will be a serious error in the upcoming update.

Here are the relevant code bits , I hope some sticks clear:

  @implementation MainView: UIView - (id) initWithCoder: (NSCoder *) aDecoder; {self = [super initWithCoder: aDecoder]; if ( } {{Self setupEvents];} return to self;} - (zero) Setup events {UITapGestureRecognizer * tapRecognizer = [[UITapGestureRecognizer alloc] InitWithTarget: Action: @selector (ShogestarTapPaper :)]; TapRecognizer.numberOfTapsRequired = 1; [Self addiculation: tape-scanner]; } - (IBAction) showGestureForTapRecognizer: (UITapGestureRecognizer *) Identifier {// gesture Get location of CGPoint location = [Identifier location: view: self]; NSLog (@ "a tap on (% F,% F)", location.x, space.i) found; [Self drawCircleX: location.x Y: location.y radius: 5 color: ([UIColor blackColor] .CGColor]];} - (zero) drawCircleX: (int) x Y: (int) y radius: (int) radius Color: (CGColorRef) fillcolor {CGContextRef reference = UIGraphicsGetCurrentContext (); // if the event handler is called from NSLog (@ "reference = 0x% 08lx", context); // CGContextSaveGState (reference); CGRCRRcode = CGRactMake X-radius, y-radius, radius * 2, radius * 2); CGContextSetFillColorWithColor (reference, filler); CGContextFillEllipseInRect (reference, rect); // CGContextRestoreGstate (reference);}  

I diarrhea To read the wages, burned for the day, to read tons of docks, but to no avail. What gives? (IOS NewB)

What you are actually doing, is creating a series of caller objects (for example, to make the casepelier alicy), which will attract itself, you implement the CALayer subclass and drawInContext : If no class is created in this is a modern approach, and possibly as complex as you are, it is as complex. But this is a better option, because it supports better performance and well animation.

If you've ever done HTML / CSS or have worked with SVG, then it's almost the same as how the client works. You have nested trees of those things that will be drawn on the screen, And you'll modify the data instead of directly portraying the GPU.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -