代码之家  ›  专栏  ›  技术社区  ›  Chilly Zhong

如何使用glgif在iPhone的子视图中显示gif?

  •  0
  • Chilly Zhong  · 技术社区  · 16 年前

    我想在iPhone的子视图中显示gif图像。示例代码glgif在控制器的根视图上显示gif图像,但是当我进行以下修改时,应用程序崩溃了:

    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);
    

    Video *vid = [[GifVideo alloc] initWithSource:src inContext:[plView context]]; 出现错误消息: -[UIView context]: unrecognized selector sent to instance . 关于如何正确地将plView添加到子视图中有什么想法吗?

    1 回复  |  直到 16 年前
        1
  •  0
  •   tc.    16 年前

    看起来plView是UIView,而不是PlayerView,并且没有名为“context”的方法。