Skip to content

Commit

Permalink
Update demo and screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
yfme committed Apr 7, 2014
1 parent 2f95ff9 commit 6d1e792
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 10 deletions.
6 changes: 6 additions & 0 deletions UIImageView-PlayGIF.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
75EEB01718E3C0CA006FC7A4 /* UIImageView_PlayGIFTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 75EEB01618E3C0CA006FC7A4 /* UIImageView_PlayGIFTests.m */; };
75EEB02118E3C0E0006FC7A4 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75EEB02018E3C0E0006FC7A4 /* QuartzCore.framework */; };
75EEB02318E3C0E4006FC7A4 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75EEB02218E3C0E4006FC7A4 /* ImageIO.framework */; };
75F09DAB18F23F7200239C6E /* TableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 75F09DAA18F23F7200239C6E /* TableViewController.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -65,6 +66,8 @@
75EEB01618E3C0CA006FC7A4 /* UIImageView_PlayGIFTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIImageView_PlayGIFTests.m; sourceTree = "<group>"; };
75EEB02018E3C0E0006FC7A4 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
75EEB02218E3C0E4006FC7A4 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; };
75F09DA918F23F7200239C6E /* TableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewController.h; sourceTree = "<group>"; };
75F09DAA18F23F7200239C6E /* TableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableViewController.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -145,6 +148,8 @@
75EEAFFD18E3C0CA006FC7A4 /* Main.storyboard */,
75EEB00018E3C0CA006FC7A4 /* ViewController.h */,
75EEB00118E3C0CA006FC7A4 /* ViewController.m */,
75F09DA918F23F7200239C6E /* TableViewController.h */,
75F09DAA18F23F7200239C6E /* TableViewController.m */,
75C8B80118E3C186000B998A /* car.gif */,
75EEB00318E3C0CA006FC7A4 /* Images.xcassets */,
75EEAFF218E3C0CA006FC7A4 /* Supporting Files */,
Expand Down Expand Up @@ -280,6 +285,7 @@
buildActionMask = 2147483647;
files = (
75EEB00218E3C0CA006FC7A4 /* ViewController.m in Sources */,
75F09DAB18F23F7200239C6E /* TableViewController.m in Sources */,
75EEAFFC18E3C0CA006FC7A4 /* AppDelegate.m in Sources */,
75EEAFF818E3C0CA006FC7A4 /* main.m in Sources */,
75C8B7FF18E3C128000B998A /* UIImageView+PlayGIF.m in Sources */,
Expand Down
22 changes: 20 additions & 2 deletions UIImageView-PlayGIF/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5023" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="bqo-O2-kuL">
<dependencies>
<deployment defaultVersion="1536" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<scenes>
<!--class Prefix:identifier View Controller-->
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
Expand All @@ -17,9 +18,26 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="g53-to-RVE"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="620" y="147"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="T4O-Zk-Bxk">
<objects>
<navigationController definesPresentationContext="YES" id="bqo-O2-kuL" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="deb-XL-YbY">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="vXZ-lx-hvc" kind="relationship" relationship="rootViewController" id="XRs-HZ-3hI"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="BLt-1u-RTm" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="180" y="147"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
Expand Down
13 changes: 13 additions & 0 deletions UIImageView-PlayGIF/TableViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// TableViewController.h
// UIImageView-PlayGIF
//
// Created by Yang Fei on 14-4-7.
// Copyright (c) 2014年 yangfei.me. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface TableViewController : UITableViewController

@end
87 changes: 87 additions & 0 deletions UIImageView-PlayGIF/TableViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
//
// TableViewController.m
// UIImageView-PlayGIF
//
// Created by Yang Fei on 14-4-7.
// Copyright (c) 2014年 yangfei.me. All rights reserved.
//

#import "TableViewController.h"
#import "UIImageView+PlayGIF.h"

@interface TableViewController ()

@end

@implementation TableViewController

- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
self.title = @"UIImageView-PlayGIF";
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
}

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

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 100;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;

UIImageView *gifView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 114, 81)];
gifView.backgroundColor = [UIColor darkGrayColor];
gifView.tag = 100;
[cell.contentView addSubview:gifView];
}
cell.detailTextLabel.text = [NSString stringWithFormat:@"index = %li",(long)indexPath.row];

UIImageView *gifView = (UIImageView *)[cell.contentView viewWithTag:100];
gifView.gifPath = [[NSBundle mainBundle] pathForResource:@"car.gif" ofType:nil];
[gifView startGIF];

return cell;
}

#pragma mark - Table view delegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 81+20;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end
25 changes: 17 additions & 8 deletions UIImageView-PlayGIF/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "ViewController.h"
#import "TableViewController.h"
#import "YFGIFImageView.h"
#import "UIImageView+PlayGIF.h"

Expand All @@ -15,6 +16,11 @@ @interface ViewController ()

@implementation ViewController

- (void)rightItemClicked:(id)sender{
TableViewController *vc = [[TableViewController alloc] initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:vc animated:YES];
}

- (void)tapped:(UITapGestureRecognizer *)gestureRecognizer {
YFGIFImageView *gifView = (YFGIFImageView *)gestureRecognizer.view;
if (gifView.isGIFPlaying) {
Expand All @@ -28,19 +34,14 @@ - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = @"UIImageView-PlayGIF";
self.view.backgroundColor = [UIColor lightGrayColor];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(self.view.frame)-60, 320, 60)];
label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
label.backgroundColor = [UIColor clearColor];
label.text = @"Size: 1.8MB x 18";
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor redColor];
[self.view addSubview:label];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(rightItemClicked:)];

NSData *gifData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"car.gif" ofType:nil]];
for (int i=0; i<18; i++) {
// user 'YFGIFImageView' or 'UIImageView+PlayGIF'
YFGIFImageView *gifView = [[YFGIFImageView alloc] initWithFrame:CGRectMake(8+i%3*(96+8), 28+i/3*(54+8), 96, 54)];
YFGIFImageView *gifView = [[YFGIFImageView alloc] initWithFrame:CGRectMake(8+i%3*(96+8), 64+28+i/3*(54+8), 96, 54)];
//UIImageView *gifView = [[UIImageView alloc] initWithFrame:CGRectMake(8+i%3*(96+8), 28+i/3*(54+8), 96, 54)];
gifView.backgroundColor = [UIColor darkGrayColor];
gifView.gifData = gifData;
Expand All @@ -52,6 +53,14 @@ - (void)viewDidLoad
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
[gifView addGestureRecognizer:tap];
}

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(self.view.frame)-60, 320, 60)];
label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
label.backgroundColor = [UIColor clearColor];
label.text = @"Size: 1.8MB x 18";
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor redColor];
[self.view addSubview:label];
}

- (void)didReceiveMemoryWarning
Expand Down
Binary file added screenshot2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6d1e792

Please sign in to comment.