Hey guys i have another problem.
I'm using a custom UIView class with the method drawRect.
No i have build a design in PaintCode and i call the method for drawing it in a drawRect method. The problem i have is that the drawRect only get's called once.
The thing i made in paintcode looks like a speedometer and the value of changes so i need to redraw it every time.
I have no idea on how to do this?
I have tried to use:
[PCView setNeedsDisplay:YES];
But that doesn't seem to work for me.
Can you guys help me out, big thanks.
Related
I am having a problem while using something like a DAScratchPad. I had this problem while drawing a line. The initial point is not moving properly and the below problem occurs when I draw the line for the first time:
In the above image I was trying to draw a straight line but after touches moved this happened. This also happens everytime after the orientation change.
Kindly help me to resolve this. Thanks in advance.
I'm developing a iOS project that involves drawing small graphics (lines and paths) on the screen.
I initially chose to use Quartz instead of OpenGL, because I need to display some basic shapes and I need to update them every 5 seconds, so I thought Quartz was better and easier.
I found out that I can't simply draw in a view, but I have to subclass a UIView and draw in the drawRect method.
In my project, the user should be able to pinch and zoom on graphics, so I planned to add a pinchgesture to the view, but I am doubtful about how to redraw everything after the pinch. Do I have to erase everything and re-add the subviews so the drawRect will trigger or is there a better way to do this?
Thanks a lot.
When using Quartz, you technically don't have to subclass the view and replace the drawRect, but it probably is best practice. When you want to redraw your window, just call [self setNeedsDisplay]; (if calling from the subclassed view, or [self.view setNeedsDisplay]; if doing it from the view controller). This will result in calling your drawRect method for you and it takes care of everything for you.
See the setNeedsDisplay documentation for more information.
Is it possible to run a cocos2d action like [CCScaleTo actionWithDuration:.3 scale:1.1] on a UIView? I know it's possible to wrap a UIView into a CCNode so you can add it as a child to a layer, but I have no idea as to how. Could anyone shed some light here? Thanks!
Edit: I've looked at CCUIViewWrapper but have had a few issues with it, namely that a) running actions on a wrapped UIView causes it to disappear and b) buttons lose their 'pushable' functionality; they're selectors aren't fired and their highlighted state isn't shown. But other than that it's great :D
Have a look at CCUIViewWrapper
http://www.cocos2d-iphone.org/forum/topic/22898
I eventually had to just use the Core Graphics equivalents to the Cocos animations when animating the UIView, and it worked well enough for me.
I've run across a couple of similar questions here regarding getting an animated MKOverlayView working property with decent performance (e.g., an animated radar overlay). However, while the answers have helped lead me in the right direction, I still don't fully grasp what I'm missing yet.
I've been trying to get this UIImageView method working, which simply adds an UIImageView as a subview of the MKOverlayView, then adds the necessary images in the animation sequence to its animationImages property. This doesn't seem to work for me as the UIImageView and its associated images are never rendered. I've even tried calling setNeedsDisplay on the overlay view which also doesn't help. In my instance, the images used in the animation have to be loaded from a remote server first and are updated fairly frequently.
There's also this method that suggests using cocos2D to setup an animated sprite, which I'd like to avoid if the above method with UIImageView works successfully.
I've been struggling with this for two days straight now, so there's likely something I'm totally missing? Do I need to use Core Graphics to do the drawing similar to how it's performed in the main drawMapRect:zoomScale:inContext: method (which I've also tried but didn't work)?
Maybe you can try this. Subclass the MKCircleView and animate a UIImageView added on it with Core Animation. It works well with the map moving around and scale with the map zoom in and out.
http://yickhong-ios.blogspot.com/2012/04/animated-circle-on-mkmapview.html
Thank you in advance for any help, I am building a multipage iPad app,and each page has specialized calculations, they all work great, but i would like to make the user experience better with some simple line drawings that represent the calculations, I am comfortable with the drawing once i get a valid CGcontext working, and this is where my problem is. I already have a webview on each page and now I want to have a UIView pop open with my drawing when the user presses the calculate button, My UIview is called drawingView and it will pop open like I want but from what i have read all drawing needs to be done within the DrawRect method in order to use the correct context. I think some of my problem is the syntax for getting the context.
Thanks for any help
Norman
Ok, I had to do what I wanted the old fashioned way, but it just seems like you should be able to get the current context of a UIView from wherever I want. By calling the view and getting it's current context. But when I do ,I get errors about not getting the current context. So, I have to make my app differently using traditional UIViews classes and bringing them into my page.