PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, July 17, 2022

[FIXED] How to load gif image and control that in ios?

 July 17, 2022     gif, ios, startup, xcode     No comments   

Issue

In my application i want load the gif images in my view and also controls stop and continue animating.when i click pause button application should stop animating and when again click start animating


Solution

Kindly follow the below tutorial that may help you. http://anand3777.blogspot.in/2014/07/gif-image-loading.html

Step 1:

   Download library from below url and add it on your project.

https://drive.google.com/folderview?id=0B5JC34Lt79ctamtOVTV6SHhzOVU&usp=sharing

Step 2:

  Import the file on your "viewController.h" like below.
  //gifImage//
  #import "SCGIFImageView.h"
 //gifImage//

Step 3:

    Create object like given below on your "viewController.h".
    //gifImage//
    IBOutlet SCGIFImageView* _gifImageView;
    IBOutlet UIButton* _button;
    //gifImage//

Step 4:

   Create ibaction on your "viewController".
   //gifImage//
    - (IBAction)controlAnimate:(id)sender;
   //gifImage//

Step 5:

   Add the following code were you want to use gif image
  //gifImage//
  //load url gif image
  NSURL *imageURL = [NSURL URLWithString:@"http://google.co.in/anim.gif"];
  NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
  /*
   //load local gif image
   NSString* filePath = [[NSBundle mainBundle] pathForResource:@"1.gif" ofType:nil];
   NSData* imageData = [NSData dataWithContentsOfFile:filePath];
 */
  _gifImageView = [[SCGIFImageView alloc] initWithFrame:CGRectMake(225, 70, 75, 75)] ;
 [_gifImageView setData:imageData];
 [self.view addSubview:_gifImageView];
 //gifImage//

Step 6:

   Add the following code for stop/start animating
  //gifImage//
  - (IBAction)controlAnimate:(id)sender{
     _gifImageView.animating = !_gifImageView.animating;

     if (_gifImageView.animating) {
         [_button setTitle:@"Pause" forState:UIControlStateNormal];
     } else {
         [_button setTitle:@"Continue" forState:UIControlStateNormal];
     }
  }
 //gifImage//


[1]: https://drive.google.com/folderview?id=0B5JC34Lt79ctamtOVTV6SHhzOVU&usp=sharing


Answered By - Anand3777
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing