Updating example project to new image request API
This commit is contained in:
parent
2610b0b57a
commit
9ee84844c4
5 changed files with 76 additions and 27 deletions
|
|
@ -58,6 +58,7 @@
|
|||
F874B5D613E0AA6500B28E3E /* AFRestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = AFRestClient.h; path = ../AFNetworking/AFRestClient.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
F874B5D713E0AA6500B28E3E /* UIImage+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImage+AFNetworking.h"; path = "../AFNetworking/UIImage+AFNetworking.h"; sourceTree = "<group>"; };
|
||||
F874B5D813E0AA6500B28E3E /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImageView+AFNetworking.h"; path = "../AFNetworking/UIImageView+AFNetworking.h"; sourceTree = "<group>"; };
|
||||
F8870C3D1424409800BCD863 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
||||
F8D25D101396A9C400CF3BD6 /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONKit.h; sourceTree = "<group>"; };
|
||||
F8D25D111396A9C400CF3BD6 /* JSONKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSONKit.m; sourceTree = "<group>"; };
|
||||
F8D25D131396A9C400CF3BD6 /* TTTLocationFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TTTLocationFormatter.h; sourceTree = "<group>"; };
|
||||
|
|
@ -174,6 +175,7 @@
|
|||
F8E469551395739C00DB05C8 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F8870C3D1424409800BCD863 /* QuartzCore.framework */,
|
||||
F8E469B71395759C00DB05C8 /* Networking Extensions */,
|
||||
F8E4696A1395739D00DB05C8 /* Classes */,
|
||||
F8E469ED1395812A00DB05C8 /* Images */,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
version = "1.3">
|
||||
version = "1.8">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
|
|
@ -36,7 +36,9 @@
|
|||
displayScale = "1.00"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug">
|
||||
buildConfiguration = "Debug"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
|
|
@ -47,6 +49,11 @@
|
|||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
<AdditionalOption
|
||||
key = "NSZombieEnabled"
|
||||
value = "YES"
|
||||
isEnabled = "YES">
|
||||
</AdditionalOption>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
|
|
@ -55,7 +62,8 @@
|
|||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release">
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
|
|
|
|||
|
|
@ -154,18 +154,20 @@
|
|||
cell = [[[SpotTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
|
||||
}
|
||||
|
||||
Spot *spot = [self.nearbySpots objectAtIndex:indexPath.row];
|
||||
|
||||
static TTTLocationFormatter *_locationFormatter = nil;
|
||||
if (!_locationFormatter) {
|
||||
_locationFormatter = [[TTTLocationFormatter alloc] init];
|
||||
[_locationFormatter setUnitSystem:TTTImperialSystem];
|
||||
}
|
||||
|
||||
Spot *spot = [self.nearbySpots objectAtIndex:indexPath.row];
|
||||
cell.textLabel.text = spot.name;
|
||||
if (self.locationManager.location) {
|
||||
cell.detailTextLabel.text = [_locationFormatter stringFromDistanceAndBearingFromLocation:self.locationManager.location toLocation:spot.location];
|
||||
}
|
||||
[cell.imageView setImageWithURL:[NSURL URLWithString:spot.imageURLString] placeholderImage:[UIImage imageNamed:@"placeholder-stamp.png"]];
|
||||
|
||||
cell.spot = spot;
|
||||
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@
|
|||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class Spot;
|
||||
|
||||
@interface SpotTableViewCell : UITableViewCell
|
||||
|
||||
@property (nonatomic, retain) Spot *spot;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -22,7 +22,12 @@
|
|||
|
||||
#import "SpotTableViewCell.h"
|
||||
|
||||
#import "Spot.h"
|
||||
|
||||
#import "UIImageView+AFNetworking.h"
|
||||
|
||||
@implementation SpotTableViewCell
|
||||
@synthesize spot = _spot;
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
|
|
@ -32,35 +37,63 @@
|
|||
|
||||
self.textLabel.textColor = [UIColor darkGrayColor];
|
||||
self.textLabel.numberOfLines = 2;
|
||||
self.textLabel.backgroundColor = self.backgroundColor;
|
||||
|
||||
self.detailTextLabel.textColor = [UIColor grayColor];
|
||||
self.detailTextLabel.backgroundColor = self.backgroundColor;
|
||||
|
||||
self.imageView.backgroundColor = self.backgroundColor;
|
||||
|
||||
self.selectionStyle = UITableViewCellSelectionStyleGray;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - UIView
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
|
||||
CGRect imageViewFrame = self.imageView.frame;
|
||||
CGRect textLabelFrame = self.textLabel.frame;
|
||||
CGRect detailTextLabelFrame = self.detailTextLabel.frame;
|
||||
|
||||
imageViewFrame.origin = CGPointMake(10.0f, 10.0f);
|
||||
imageViewFrame.size = CGSizeMake(50.0f, 50.0f);
|
||||
|
||||
textLabelFrame.origin.x = imageViewFrame.size.width + 25.0f;
|
||||
detailTextLabelFrame.origin.x = textLabelFrame.origin.x;
|
||||
|
||||
textLabelFrame.size.width = 240.0f;
|
||||
detailTextLabelFrame.size.width = textLabelFrame.size.width;
|
||||
|
||||
self.textLabel.frame = textLabelFrame;
|
||||
self.detailTextLabel.frame = detailTextLabelFrame;
|
||||
self.imageView.frame = imageViewFrame;
|
||||
- (void)dealloc {
|
||||
[_spot release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)setSpot:(Spot *)spot {
|
||||
[self willChangeValueForKey:@"spot"];
|
||||
[_spot autorelease];
|
||||
_spot = [spot retain];
|
||||
[self didChangeValueForKey:@"spot"];
|
||||
|
||||
[self.imageView setImageWithURL:[NSURL URLWithString:self.spot.imageURLString] placeholderImage:[UIImage imageNamed:@"placeholder-stamp.png"]];
|
||||
|
||||
self.textLabel.text = spot.name;
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewCell
|
||||
|
||||
- (void)prepareForReuse {
|
||||
[self.imageView cancelImageRequestOperation];
|
||||
self.textLabel.text = nil;
|
||||
self.detailTextLabel.text = nil;
|
||||
}
|
||||
|
||||
#pragma mark - UIView
|
||||
|
||||
//- (void)layoutSubviews {
|
||||
// [super layoutSubviews];
|
||||
//
|
||||
// CGRect imageViewFrame = self.imageView.frame;
|
||||
// CGRect textLabelFrame = self.textLabel.frame;
|
||||
// CGRect detailTextLabelFrame = self.detailTextLabel.frame;
|
||||
//
|
||||
// imageViewFrame.origin = CGPointMake(10.0f, 10.0f);
|
||||
// imageViewFrame.size = CGSizeMake(50.0f, 50.0f);
|
||||
//
|
||||
// textLabelFrame.origin.x = imageViewFrame.size.width + 25.0f;
|
||||
// detailTextLabelFrame.origin.x = textLabelFrame.origin.x;
|
||||
//
|
||||
// textLabelFrame.size.width = 240.0f;
|
||||
// detailTextLabelFrame.size.width = textLabelFrame.size.width;
|
||||
//
|
||||
// self.textLabel.frame = textLabelFrame;
|
||||
// self.detailTextLabel.frame = detailTextLabelFrame;
|
||||
// self.imageView.frame = CGRectIntegral(imageViewFrame);
|
||||
//}
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue