adding a complex animation without using UIImage - iphone

i want to create a childrens book like this one:
http://www.youtube.com/watch?v=Sc1APRfP2o8
and i wanted to know, How do i create the animations? I have searched and all i can find are creating animations via putting together UIImages and then playing them. But i sure hope i do not have to do this with my whole book. I was wondering if there is another program i could use to create the animation in and then import it into Xcode and then just call it to play. Is this possible? Thanks a bunch!

Check out Cocoas2D.

I didn't watch the video but if you want to create an animation easily aybe you can try gif
NSData *gif = [NSData dataWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:#"filename" ofType:#"gif"]];
UIWebView *view = [[UIWebView alloc] initWithFrame:frame];
[view loadData:gif MIMEType:#"image/gif" textEncodingName:nil baseURL:nil];
this might work

Related

UIImageView not displaying image in ipad

I am loading image from url coming from xml image not showing image
CGRect mywebframe=CGRectMake(0,60,700,300);
UIImageView*imageView=[[UIImageView alloc] initWithFrame:mywebframe];
NSString*imageurl=aBook.image;
imageurl=[imageurl stringByReplacingOccurenceOfString:#"\n" withString:#""];
imageurl=[imageurl stringByTrimmingCharacterInSet:[NSCharacterSet whitespaceCharacterSet]];
NSURL*url=[NSURL URLWithString:imageurl];
NSData*data=[[NSData alloc] initWithContentsOfURL:url];
UIImage*imagetemp=[[UIImage alloc] initWithData:data];
imageView.image=imagetemp;
[subView addSubView:imageView];
I bet your image (imagetemp) is nil.
Too many possibilities why it is nil. Try to log every variable before you use it and you'll find the bug quickly.
Firstly, you can use NSLog() to make sure your URL is correct.
Secondly, you really can not get the image that simple. I recommend a ImageView named EGOImageView You only need to give a place holding image and a URL, you can have the an asynchronized imageView.It also cache images for you automatically.

objective c MPMoviePlayerController wont work on iOS 4.3

Ive got this code from an ebook tutorial on embedding MPMoviePlayerController from a VIEW object but it just dont work at all on iOS 4.3, it just gives me a black screen. I've tried looking at other sources and they have the same source code. Can anyone help me on finding what is the problem in this code.
Thanks
- (IBAction)playMovie:(id)sender {
NSString *filepath = [[NSBundle mainBundle] pathForResource:#"shawarma" ofType:#"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[player.view setFrame: movieHolder.bounds];
[movieHolder addSubview: player.view];
[player play];
}
My VIEW object has a dimension of 400 x 300.
From the MPMoviePlayerController class reference guidelines Consider
a movie player view to be an opaque structure.
You can add your own custom subviews to layer content on top of the
movie but you must never modify any of its existing subviews.
In addition to layering content on top of a movie, you can provide
custom background content by adding
subviews to the view in the backgroundView
MPMoviePlayerController it self has a property view to present the video
Hope this LINK might help you
There is no issue with MPMoviePlayer and ios 4.3 i am working on an application that plays movie from a server and this is working fine for me. I request you to check
Path of you resource try some hardcode path.
Frame of the MoviePlayer.
Thanks

Image Swiping In Objective-C

I'm just a beginner to iphone development.
Recently i'm doing a project in which images need to be swiped. Could any one help me with it?
The images are stored in a server whose link is given.
I'm need it badly. So please help me
thank you
There are two ways.
You could either look at using a Paging Scroll View
Or, You could look at getting a series of UIImageViews with the correct images in each and then setting up a UISwipeGestureRecogniser for both directions. On the swipe's event handler you can adjust the x and y positions of the imageViews.
This is basic stuff. You should read some of the How-to's on Apple's developer website to help you with the base knowledge.
Edit:
Regarding the Internet images, the code can be adapted into the paging scroll view example:
NSString *path = #"http://merrimusings.mu.nu/archives/images/groundhog2.jpg";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data cache:NO];
Load the strings from an NSMutableArray instead and you're good to go!
Use Three20 photo Album. Your problem will be solved.

How do i insert UIImage on UIWebView

I'm trying to display an Animated-GIF image in a UIImageView. Because this way only the first frame is shown i wanted to try a different approach.
UIWebView.
How can i get an Animated-GIF that is in memory (NSData) to display on a UIWebView with all frames..?
Thanks Thomas for you response, i don't know if it works because i managed to do it myself now..
Been decoding the GIFs for more then a week now and still with no succes so i went from UIImageView to UIWebView and the following code made it work..
[self.webView loadData:gifData MIMEType:#"image/gif" textEncodingName:nil baseURL:nil];
I've not tried it, but something like this :
NSString *html = [NSString stringWithFormat:#"<img src='data:image/gif;base64,%#' />", [myData base64Value];
[myWebView loadHTMLString:html baseURL:nil]
You'll need a NSData category that implements converting to base64, that shouldn't be difficult to find (I've bookmarked http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html)
edit: another way is to decode the gif, so you have an NSArray of the frames : http://pliep.nl/blog/2009/04/iphone_developer_decoding_an_animated_gif_image_in_objc
http://blog.stijnspijker.nl/2009/07/animated-and-transparent-gifs-for-iphone-made-easy/

How to get path to add number of Images that are in the resource to be displayed in the WebView in objective-c

I am added image to my application but I want to display them into my web view. I tried but not succeeded. how can I set the path for those images in html in image tag and how to display them.
Please help me out of this.
Thank you,
Madan Mohan.
Are you just displaying the images individually or do you have an HTML file that references them?
To get a URL to the files directly:
NSString *pathForImage = [[NSBundle mainBundle] pathForResource:#"image" ofType:#"png"];
NSURL *URL = [NSURL fileURLWithPath:pathForImage];
If you're loading an HTML file that references the images (such as by including an <img src="image.png">, with no path info) then:
[webView loadHTMLString:htmlString
baseURL:[[NSBundle mainBundle] resourceURL]];
EDIT: so, supposing you had image.png in your application bundle as a resource, then you could do:
[webView loadHTMLString:#"<html><body><img src=\"image.png\"></body></html>"
baseURL:[[NSBundle mainBundle] resourceURL]];
In your HTML for the webview do
<img src="imagename">
Where imagename is the filename of the image. The iPhone doesn't have any folder structures or anything like that. That means that even if you have groups or folders set up in XCode, at runtime they are all lumped into one, giant directory.
If that doesn't work right away, look at what your are setting your base url to be. It might be that you need to set the baseURL to nil to remind the phone to look locally.
The following code sample might fix the problem for you.. Good luck!
NSData * image = [[NSMutableData alloc] initWithContentsOfFile:#"image.png"];
[self.webView loadData:image MIMEType:#"image/png" textEncodingName:nil baseURL:nil];
[image release];
[self.view addSubView:webView];