How can display gif on a subview in iPhone using glgif?

Posted by iPhoney on Stack Overflow See other posts from Stack Overflow or by iPhoney
Published on 2010-06-10T13:41:13Z Indexed on 2010/06/11 2:22 UTC
Read the original article Hit count: 318

Filed under:
|

I want to display a gif image on a subview in iPhone. The sample code glgif shows the gif image on the controller's root view, but when I make the following modifications, the application just crashes:

IBOutlet UIView *gifView;  // gifView is added as a subview of controller's root view

//PlayerView *plView = (PlayerView *)self.view;
PlayerView *plView = (PlayerView *)gifView;

// Load test.gif VideoSource
NSString *str = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"gif"];
FILE *fp = fopen([str UTF8String], "r");
VideoSource *src = VideoSource_init(fp, VIDEOSOURCE_FILE);
src->writeable = false;

// Init video using VideoSource
Video *vid = [[GifVideo alloc] initWithSource:src inContext:[plView context]];
VideoSource_release(src);

// Start if loaded
if (vid) {
    [plView startAnimation:vid];
    [vid release];
    return;
}

// Cleanup if failed
fclose(fp);

Now the app crashes in this line: Video *vid = [[GifVideo alloc] initWithSource:src inContext:[plView context]]; with the error message:-[UIView context]: unrecognized selector sent to instance. Any ideas about how to add the plView to the subview properly?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about gif