2016-10-05 55 views
1

私はこれに続いてGIFイメージを表示するpostを表示します。GIFイメージが表示されません

私が試してみました:

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 

    UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds]; 
    animatedImageView.animationImages = [NSArray arrayWithObjects: 
             [UIImage imageNamed:@"splash.gif"], nil]; 
    animatedImageView.animationDuration = 6.0f; 
    animatedImageView.animationRepeatCount = 10; 
    [animatedImageView startAnimating]; 
    [self.view addSubview: animatedImageView]; 
} 


- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 


@end 

私は私のプロジェクトにGIF画像を追加しました。しかし、GIFイメージは表示されません。

+0

はこの一回http://stackoverflow.com/questions/4386675/add-animated-gif-image-in-iphone-uiimageview –

+0

@ Anbu.Karthik、私は上記の言及と同じリンクを参照してください。 – Khuong

+0

ああ、ごめんなさい、あなたが単一のgifの使用をしたい場合UIWebviewは最高のオプションです –

答えて

0

iOSはGIFイメージをサポートしていません。アニメーション化するために連鎖することができる静的イメージのシーケンスだけです。また、複数のフレームに分割して実行するため、外部ライブラリを使用してUIImageViewawesome-ios

1

にいくつかのライブラリをチェックしますが、GIFイメージをロードするためのUIWebViewを使用することができます。私は私のアプリで使用しています

NSString *pathForFile = [[NSBundle mainBundle] pathForResource: @"splash" ofType: @"gif"]; 
    NSData *dataOfGif = [NSData dataWithContentsOfFile: pathForFile]; 
    [Web_View loadData:dataOfGif MIMEType:@"image/gif" textEncodingName:nil baseURL:nil]; 

利用コード:

NSString *pathForFile = [[NSBundle mainBundle] pathForResource: @"splash" ofType: @"gif"]; 
    NSData *dataOfGif = [NSData dataWithContentsOfFile: pathForFile]; 

     UIWebView *Web_View = [[UIWebView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height)]; 
    [Web_View loadData:dataOfGif MIMEType:@"image/gif" textEncodingName:@"" baseURL:[NSURL URLWithString:@""]]; 
     [self.view addSubview:Web_View]; 

またはこのチェック:

https://github.com/mayoff/uiimage-from-animated-gif

+0

こんにちは@Abhisheck Gupta、あなたのコードを試しましたが、gif画像が表示されません。 – Khuong

+0

@Khuongは私の仕事です。どこに問題がありますか? –

+0

Ahh、ok。しかし、gifのフレームは正しく表示されません。 – Khuong

1

....このライブラリを使用し

https://github.com/mayoff/uiimage-from-animated-gif

と.gifファイルのロードのために、このコードを配置します。

"YOURIMAGEVIEW".image = [UIImage animatedImageWithAnimatedGIFURL:"YOUR_URL_OF_IMAGE"] 
+0

http://stackoverflow.com/users/4742830/khuong私のコードを試してください。 –

+0

ライブラリを使うことは私の仕事です。 – Khuong

+0

私の答えを承認@Khuong –

関連する問題