开发者

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

I want to display a gif image on a subview in iPhone. The sa开发者_StackOverflow社区mple 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?


Looks like plView is a UIView, not a PlayerView, and does not have a method called "context".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜