-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented simple custom activity indicator.
- Supports loading from device or remotely (synchronously). - Supports resizing. - Fixed memory leak.
- Loading branch information
Showing
6 changed files
with
145 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
project_files/Plugins/wizSpinnerPlugin/WizActivitySpinnerView.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// WizActivitySpinnerView.h | ||
// practical_test_01 | ||
// | ||
// Created by Chris Wynn on 7/22/12. | ||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface WizActivitySpinnerView : UIImageView | ||
|
||
- (id)initWithImageURL:(NSURL *)url; | ||
- (void)setSize:(CGSize)size; | ||
|
||
@end |
56 changes: 56 additions & 0 deletions
56
project_files/Plugins/wizSpinnerPlugin/WizActivitySpinnerView.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// WizActivitySpinnerView.m | ||
// practical_test_01 | ||
// | ||
// Created by Chris Wynn on 7/22/12. | ||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "WizActivitySpinnerView.h" | ||
#import <ImageIO/ImageIO.h> | ||
|
||
@implementation WizActivitySpinnerView | ||
|
||
- (id)initWithImageURL:(NSURL *)url | ||
{ | ||
// For remote URLs, the read of data below will make app unresponsive. | ||
|
||
// TODO: Consider changing to asynchronous or background loading of URL data | ||
|
||
// Read data from the URL | ||
NSData *data = [NSData dataWithContentsOfURL:url]; | ||
|
||
// Split data into individual frames using ImageIO (iOS4.0 and above). | ||
NSMutableArray *frames = nil; | ||
CGImageSourceRef imgSource = CGImageSourceCreateWithData((CFDataRef)data, NULL); | ||
if ( imgSource ) { | ||
size_t count = CGImageSourceGetCount(imgSource); | ||
frames = [NSMutableArray arrayWithCapacity:count]; | ||
for ( size_t i = 0; i < count; i++ ) { | ||
CGImageRef img = CGImageSourceCreateImageAtIndex(imgSource, i, NULL); | ||
if ( img ) { | ||
[frames addObject:[UIImage imageWithCGImage:img]]; | ||
CGImageRelease(img); | ||
} | ||
} | ||
CFRelease(imgSource); | ||
} | ||
|
||
// Initialize with the frame data. Note that if frames is nil, | ||
// both the image and animationImages will be initialized to nil. | ||
self = [super initWithImage:[frames objectAtIndex:0]]; | ||
if (self) { | ||
self.animationImages = frames; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)setSize:(CGSize)size | ||
{ | ||
CGRect myBounds = self.bounds; | ||
myBounds.size = size; | ||
self.bounds = myBounds; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters