on view load, start a timer and reveal images at times in iPad app - objective-c

So in my XIB I have a few graphics that need to reveal in order.. say every one second, the next thing will reveal..
I assume I am going to need something involving viewdidload, starting an NSTimer, then animate the revealing of my graphics with the timer. Can anyone please drop me a few ideas, hints or lines of code to get started?
Thanks!

You could use Quartz Composer to build your image sequence, and then render that to a QCView or OpenGL context.

Related

Movement of objects in game

I have a queston about movment of object in app (game) I am creating. I tried move ImageView with timer. So every 0.01 second object move for 1px. But movement is not smooth. So i also tried with animations. But there is problem, that if I close app and run it again (app was stil opened in background), there are problems, that picture of View stays on the end of animation. And also I want to check every 0.01 second if moving object and my character did colide, so animation is not the best option. Is there a way to move my object smooth with local time on phone? Or there is some other way to move object?
It sounds like you're not using SpriteKit or any game engine for that matter. Any game engine will come with an update loop that does all of this.
You can learn about SpriteKit here... http://www.raywenderlich.com/42699/spritekit-tutorial-for-beginners

How to acheive animation effects like(word puzzle game) in iphone application?

i need to achieve an animation effect like (the Effects in "Pic Something","Pic Reveal" and so on) in my app.
What i am saying is i need to implement this tasks
Task1: when the user touches one Letter, then it change its frame(current position) to another frame(target position).
Task2:when the user touch the Letter(in Target position), it comes back to its original position again.
this can be clearly understood if u see the sample Apps.
I didn't find out any samples on internet also.
Thanks in Advance..
Take a look at UIView animation and animation blocks in iOS, that's what you need. With them you can create any animation you like. Here's a nice tutorial.
And about the whole system you described - I would create an NSDictionary of UIView positions and attach those to the corresponding tags of UIViews- this way you will always know from which place every UIView came from.

Why do I get a delay when executing animations first time?

I am using imageWithContentsOfFile: to load my .png images into an array. When the IBAction triggers the animation, there is a noticeable delay before the animation starts. Then, each time after that, it executes smoothly. I originally tried to load them with the imageNamed: method but experienced the same delay plus big performance problems on the device.
Load the images in ViewWillLoad instead.
If that doesn't work, use the developer tool Instruments (built into xcode) to find what is causing the performance hit. Choose Open GL ES driver, under the iOS -> graphics menu. Then tick Hide system libraries. Then it will show you which methods are taking a long time, click into those methods to see exactly which lines, then just try and figure out alternative ways to do it.

Drawing with UIKit and preload it

I am drawing a graph with UIKIT and I want to show before it is finished a preloader (spinning circle)
Another solution should be before start drawing set the alpha of my view to 0.0 and when it's done fade it to 1.0.
Someone did this before and/or know how to do this?
If using UIKit, you could draw the path, fill and stroke, then draw another path. This is resource-intensive as you will be calling drawRect: often.
The other way is to create animation. I'll let someone else as I have no experience in creating animation in iOS.
You could add an activity indicator to the view, send the view setNeedsDisplay and remove the activity indicator at the end of the drawRect:, but I doubt you will see the activity indicator at all. Activity indicators are only useful when you are performing some lengthy operations, taking at least several seconds to complete. If drawing the graph is that long, you should either optimize it or consider drawing it on a secondary thread into a CGImage. In the latter case, I'm afraid, you restrict yourself to Core Graphics.

Unload image of UIImageView thats offscreen

I'm coding an application on Ipad, in a certain point of my application I present a ViewController with the presentModalViewController.
My ViewController is a UISScrollView who take the larger of the modalView and inside it I display some images, I allow pagingEnabled so I can see all my images inside the scrollView.
Sometimes I have to display more than 10 images inside the scrollView, so I have this error
RECEIVE MEMORY WARNING LEVEL=1 after this one RECEIVE MEMORY WARNING LEVEL=2 and finnaly the debugger exited due to signal 10 (Sigbus).
What can I do? is there a way to unload the image thats offscreen? or others things to do?
Thanks,
I guess you're adding all the images to the UIScrollView? Then the iPad has to keep all 10 images in memory. If they are full screen images, each of them will take up about 3 MB of memory, so you're using 30MB just to keep the 10 images in the scroll view.
You should only add the one or two images that are actually visible. Once they scroll out of sight, remove the UIImageView from your UIScrollView (and make sure you don't retain it anywhere else so it can be deallocated). When a new image scrolls into sight, add it to the UIScrollView only then.
In your UIScrollViewDelegate method -scrollViewDidScroll: get the current contentOffset and use that to calculate which images are visible.
Actually, this problem is even worse on the iPhone 3G, which can't even manage to display two full size photos (taken with it's own camera) at the same time.
If you can make the photos smaller ahead of time by resizing them (server side if you're snagging them from your own services, or client side if they're somehow generated on the device or retrieved from third party services), you should. They will load faster, and you can put more of them on the screen at once without running into memory issues.
The Three20 library has a really great photo-browsing control for the iPhone. I'm pretty sure they only have three photos around at any given time... the photo you're looking at, and the photos going forward or backwards.
http://github.com/facebook/three20
I also think there is an iPad branch of the Three20 controls (at ./tree/ipad), although I don't know if they include the photo browser or not, and haven't tried them yet myself... maybe that's an option for you if you don't want to spend a lot of time on that particular feature of your application. If the iPad photo browser isn't done maybe you could just adapt the iPhone version to suit your needs (shouldn't be hard).
If you want to bake the feature yourself, I'd take some inspiration from the UITableViewController. Your controller should come with associated datasource and delegate protocols to retrieve photos and respond to user events. The controller base class itself should reuse three UIImageViews and should shuffle those around to create the illusion that the user is scrolling through a large list.