gpt4 book ai didi

ios - Three20 TTPhotoViewController 不显示照片

转载 作者:行者123 更新时间:2023-11-29 05:06:18 26 4
gpt4 key购买 nike

我已经完成了一些教程,包括示例应用程序与 Three20 一起使用,无法弄清楚为什么照片没有显示在我的TTPhotoViewController。事实上我发现调试起来非常困难。下面是我的代码。关于为什么图像无法加载的任何想法以及如何调试它会很棒。我得到了一个全黑的 View 在我的底部标签栏和上部导航栏之间。我也看到左和右箭头覆盖在黑色 View 上,似乎用于导航照片,虽然我认为它应该显示缩略图画廊。

// A TTPhoto class 
// Photo.h
#import <Foundation/Foundation.h>
#import <Three20/Three20.h>
@interface Photo : NSObject <TTPhoto> {
NSString *_caption;
NSString *_urlLarge;
NSString *_urlSmall;
NSString *_urlThumb;
id <TTPhotoSource> _photoSource;
CGSize _size;
NSInteger _index;
}

@property (nonatomic, copy) NSString *caption;
@property (nonatomic, copy) NSString *urlLarge;
@property (nonatomic, copy) NSString *urlSmall;
@property (nonatomic, copy) NSString *urlThumb;
@property (nonatomic, assign) id <TTPhotoSource> photoSource;
@property (nonatomic) CGSize size;
@property (nonatomic) NSInteger index;
- (id)initWithCaption:(NSString *)caption urlLarge:(NSString
*)urlLarge urlSmall:(NSString *)urlSmall urlThumb:(NSString *)urlThumb
size:(CGSize)size;
@end

// Photo.m
#import "Photo.h"
@implementation Photo
@synthesize caption = _caption;
@synthesize urlLarge = _urlLarge;
@synthesize urlSmall = _urlSmall;
@synthesize urlThumb = _urlThumb;
@synthesize photoSource = _photoSource;
@synthesize size = _size;
@synthesize index = _index;
- (id)initWithCaption:(NSString *)caption urlLarge:(NSString
*)urlLarge urlSmall:(NSString *)urlSmall urlThumb:(NSString *)urlThumb
size:(CGSize)size {
if ((self = [super init])) {
self.caption = caption;
self.urlLarge = urlLarge;
self.urlSmall = urlSmall;
self.urlThumb = urlThumb;
self.size = size;
self.index = NSIntegerMax;
self.photoSource = nil;
}
return self;
}

- (void) dealloc {
self.caption = nil;
self.urlLarge = nil;
self.urlSmall = nil;
self.urlThumb = nil;
[super dealloc];
}

#pragma mark TTPhoto
- (NSString*)URLForVersion:(TTPhotoVersion)version {
switch (version) {
case TTPhotoVersionLarge:
return _urlLarge;
case TTPhotoVersionMedium:
return _urlLarge;
case TTPhotoVersionSmall:
return _urlSmall;
case TTPhotoVersionThumbnail:
return _urlThumb;
default:
return nil;
}
}

@end

// A TTPhotoSource class
// PhotoSet.h
#import <Foundation/Foundation.h>
#import "Three20/Three20.h"
@interface PhotoSet : TTURLRequestModel <TTPhotoSource> {
NSString *_title;
NSArray *_photos;
NSArray* _tempPhotos;
NSTimer* _fakeLoadTimer;
}

@property (nonatomic, copy) NSString *title;
@property (nonatomic, retain) NSArray *photos;
- (id) init;
@end

// PhotoSet.m
#import "PhotoSet.h"
#import "Photo.h"
@implementation PhotoSet
@synthesize title = _title;
@synthesize photos = _photos;
- (id) init {
_title = @"Test photo album";
_photos = [[NSArray alloc] initWithObjects:
[[[Photo alloc] initWithCaption:@"coming soon"
urlLarge:@"http://farm5.static.flickr.com/
4066/4653156849_0905e6b58e_o.jpg"
urlSmall:@"http://farm5.static.flickr.com/
4066/4653156849_0d15f0e3f0_s.jpg"
urlThumb:@"http://farm5.static.flickr.com/
4066/4653156849_0d15f0e3f0_s.jpg"
size:CGSizeMake(220, 112)] autorelease],
[[[Photo alloc] initWithCaption:@"coming soon 2"
urlLarge:@"http://farm5.static.flickr.com/
4023/4653774402_05e6acd995_o.jpg"
urlSmall:@"http://farm5.static.flickr.com/
4009/4653157237_c2f5f59e0d_s.jpg"
urlThumb:@"http://farm5.static.flickr.com/
4009/4653157237_c2f5f59e0d_s.jpg"
size:CGSizeMake(220, 112)] autorelease],
[[[Photo alloc] initWithCaption:@"coming soon 2"
urlLarge:@"http://farm5.static.flickr.com/
4023/4653774402_05e6acd995_o.jpg"
urlSmall:@"http://farm5.static.flickr.com/
4009/4653157237_c2f5f59e0d_s.jpg"
urlThumb:@"http://farm5.static.flickr.com/
4009/4653157237_c2f5f59e0d_s.jpg"
size:CGSizeMake(220, 112)] autorelease],
[[[Photo alloc] initWithCaption:@"coming soon 2"
urlLarge:@"http://farm5.static.flickr.com/
4023/4653774402_05e6acd995_o.jpg"
urlSmall:@"http://farm5.static.flickr.com/
4009/4653157237_c2f5f59e0d_s.jpg"
urlThumb:@"http://farm5.static.flickr.com/
4009/4653157237_c2f5f59e0d_s.jpg"
size:CGSizeMake(220, 112)] autorelease],
nil];
for (int i = 0; i < _photos.count; ++i) {
id<TTPhoto> photo = [_photos objectAtIndex:i];
if ((NSNull*)photo != [NSNull null]) {
NSLog(@"in here 65434");
photo.photoSource = self;
photo.index = i;
}
}
return self;
}

- (void) dealloc {
self.title = nil;
self.photos = nil;
[super dealloc];
}

#pragma mark TTModel
- (BOOL)isLoading {
return NO;
}

- (BOOL)isLoaded {
return YES;
}

#pragma mark TTPhotoSource
- (NSInteger)numberOfPhotos {
return _photos.count;
}

- (NSInteger)maxPhotoIndex {
return _photos.count-1;
}

- (id<TTPhoto>)photoAtIndex:(NSInteger)photoIndex {
if (photoIndex < _photos.count) {
return [_photos objectAtIndex:photoIndex];
} else {
return nil;
}
}

@end

// A TTPhotoViewController
// EventDetailViewController.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <Three20/Three20.h>
#import "PhotoSet.h"
@class Event;
@interface EventDetailViewController :
TTPhotoViewController<UINavigationControllerDelegate,
UIImagePickerControllerDelegate> {
NSArray *photos;
Event *event;
PhotoSet *_photoSet;
}

@property (nonatomic, retain) NSArray *photos;
@property (nonatomic, retain) Event *event;
@property (nonatomic, retain) PhotoSet *photoSet;
- (id)initWithEvent:(Event *)e;

// EventDetailViewController.m
#import "EventDetailViewController.h"
#import "Event.h"
#import "PhotoSet.h"
#import "Photo.h"
@implementation EventDetailViewController
@synthesize photos;
@synthesize event;
@synthesize photoSet = _photoSet;
#pragma mark -
#pragma mark Initialization
- (void)viewDidLoad {
self.photoSet = [[PhotoSet alloc] init];
self.photoSource = self.photoSet;
}

- (id)initWithEvent:(Event *)e {
if (self) {
self.event = e;
}
return self;
}

@end

最佳答案

关于ios - Three20 TTPhotoViewController 不显示照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5038443/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com