2011-02-13 16 views
0

3 개의 20 개의 라이브러리를 사용하는 프로젝트를 진행하고 있습니다. 이 프로젝트의 일부로 TTThumbsViewController에 이미지를로드하고 표시해야합니다. 이미지를 다운로드하고 사진 객체를 설정하는 코드는 실행되지만 이미지는 표시되지 않습니다.TTThumbsViewController 이미지가 표시되지 않습니다.

개체을 준수합니다 Please refer to attached image.

However, if I use the same datasource for TTPhotoViewController everything works just fine. I am using 1.0.3 version of the Three20 library. The code of setting up the datasource is 


@interface FeedPhotoSource : TTModel <TTPhotoSource> { 
    NSString* _title; 
    NSMutableArray* _photosToBeLoaded; 
    NSMutableArray * _loadedPhotosArray; 
} 

@property(retain) NSNumber * ownderId; 
- (id)initWithTitle:(NSString*)title photos:(NSArray*)photos ownerId:(NSNumber*)ownerId; 

@end 

/////////////////////////////////////////////////////////////////////////////////////////////////// 

@interface FeedPhoto : NSObject <TTPhoto> { 
    id<TTPhotoSource> _photoSource; 
    NSString* _thumbURL; 
    NSString* _smallURL; 
    NSString* _URL; 
    CGSize _size; 
    NSInteger _index; 
    NSString* _caption; 
} 

- (id)initWithURL:(NSString*)URL smallURL:(NSString*)smallURL size:(CGSize)size; 

- (id)initWithURL:(NSString*)URL smallURL:(NSString*)smallURL size:(CGSize)size 
      caption:(NSString*)caption; 

@property(retain, nonatomic) NSString* thumbURL; 
@property(retain, nonatomic) NSString* smallURL; 
@property(retain, nonatomic) NSString* URL; 

@end 

그리고 구현이 질문에 아마 이미 해결되었다,하지만

#import "FeedPhotoSource.h" 
#import "FacebookGetPhotosRequest.h" 
#import "FeedDataRecord.h" 

@implementation FeedPhotoSource 

@synthesize title = _title; 
@synthesize ownderId; 

/////////////////////////////////////////////////////////////////////////////////////////////////// 
// NSObject 

- (id)initWithTitle:(NSString*)title photos:(NSArray*)photos ownerId:(NSNumber*)ownerId 
{ 
    if (self = [super init]) { 
     _title = [title copy]; 
     _photos = photos?[photos mutableCopy] : [[NSMutableArray alloc] init]; 
     self.ownderId = ownerId; 
     _loadedPhotosArray = [[NSMutableArray alloc] initWithCapacity:4]; 
     _request = nil; 

    } 
    return self; 
} 

- (id)init 
{ 
    return [self initWithTitle:nil photos:nil ownerId:nil]; 
} 

- (void)dealloc 
{ 
    TT_RELEASE_SAFELY(ownderId); 
    TT_RELEASE_SAFELY(_photos); 
    TT_RELEASE_SAFELY(_title); 
    TT_RELEASE_SAFELY(_loadedPhotosArray); 
    TT_RELEASE_SAFELY(_request); 
    [super dealloc]; 
} 

/** 
* Indicates that the data has been loaded. 
* 
* Default implementation returns YES. 
*/ 
- (BOOL)isLoaded 
{ 
    int count = [_loadedPhotosArray count] ; 
    return (count != 0); 
} 

/** 
* Indicates that the data is in the process of loading. 
* 
* Default implementation returns NO. 
*/ 
- (BOOL)isLoading 
{ 
    if (self.isLoaded) 
    { 
     return NO; 
    } 
    return (_request != nil); 
} 

- (BOOL)shouldLoadMore 
{ 
    return NO; 
} 

/////////////////////////////////////////////////////////////////////////////////////////////////// 
// TTModel 

- (void)load:(TTURLRequestCachePolicy)cachePolicy more:(BOOL)more 
{ 
    if (_request != nil) 
    { 
     TT_RELEASE_SAFELY(_request); 
    } 
     NSMutableArray * _photosArray = [NSMutableArray array]; 

     for(MediaObjectLoadStatus * mediaObjectEntry in _photos) 
     { 
      [_photosArray addObject:mediaObjectEntry.photoId]; 
      FeedPhoto * photo = [[[FeedPhoto alloc] initWithURL:mediaObjectEntry.mediaPath smallURL:mediaObjectEntry.mediaPath size:CGSizeMake(320, 480)] autorelease]; 
      photo.pid = mediaObjectEntry.photoId; 
      [_feedPhotoArray addObject:photo]; 
     } 
     _request = [[MyRequest alloc] initWithPhotoIds:_photosArray andOwner:ownderId]; 
     _request.delegate = self; 
     [_request fetchPhotos]; 

} 

/** 
* Cancels a load that is in progress. 
* 
* Default implementation does nothing. 
*/ 
- (void)cancel 
{ 
    if (_request != nil) 
    { 
     [_request cancelPreviousRequest]; 
     TT_RELEASE_SAFELY(_request); 
    } 

    [self didCancelLoad]; 
} 

-(void) Request: (myRequest*)request CompletedSuccessfullyWithResult:(id) result 
{ 
    NSMutableArray * resultObj = result; 

    //Extract and update photosObject 


    [self didFinishLoad]; 
} 
-(void) Request: (myRequest*)request CompletedWithFailure:(NSError *) error 
{ 
    [self didFailLoadWithError:error]; 

} 



/////////////////////////////////////////////////////////////////////////////////////////////////// 
// TTPhotoSource 

- (NSInteger)numberOfPhotos 
{ 
    return _photos.count; 
} 

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

- (id<TTPhoto>)photoAtIndex:(NSInteger)photoIndex { 
    if (photoIndex < _feedPhotoArray.count) { 
     id photo = [_feedPhotoArray objectAtIndex:photoIndex]; 
     if (photo == [NSNull null]) 
     { 
      return nil; 
     } 
     else 
     { 
      return photo; 
     } 
    } 

    return nil; 

} 

@end 

/////////////////////////////////////////////////////////////////////////////////////////////////// 

@implementation FeedPhoto 

@synthesize photoSource = _photoSource, size = _size, index = _index, caption = _caption; 
@synthesize thumbURL = _thumbURL; 
@synthesize smallURL = _smallURL; 
@synthesize URL = _URL; 

/////////////////////////////////////////////////////////////////////////////////////////////////// 
// NSObject 

- (id)initWithURL:(NSString*)URL smallURL:(NSString*)smallURL size:(CGSize)size { 
    return [self initWithURL:URL smallURL:smallURL size:size caption:nil]; 
} 

- (id)initWithURL:(NSString*)URL smallURL:(NSString*)smallURL size:(CGSize)size 
      caption:(NSString*)caption { 
    if (self = [super init]) { 
     _photoSource = nil; 
     _URL = [URL copy]; 
     _smallURL = [smallURL copy]; 
     _thumbURL = [smallURL copy]; 
     _size = size; 
     _caption = [caption copy]; 
     _index = NSIntegerMax; 
    } 
    return self; 
} 

- (void)dealloc { 
    TT_RELEASE_SAFELY(_URL); 
    TT_RELEASE_SAFELY(_smallURL); 
    TT_RELEASE_SAFELY(_thumbURL); 
    TT_RELEASE_SAFELY(_caption); 
    [super dealloc]; 
} 

/////////////////////////////////////////////////////////////////////////////////////////////////// 
// TTPhoto 

- (NSString*)URLForVersion:(TTPhotoVersion)version { 
    if (version == TTPhotoVersionLarge) { 
     return _URL; 
    } else if (version == TTPhotoVersionMedium) { 
     return _URL; 
    } else if (version == TTPhotoVersionSmall) { 
     return _smallURL; 
    } else if (version == TTPhotoVersionThumbnail) { 
     return _thumbURL; 
    } else { 
     return nil; 
    } 
} 

@end 
+0

추가 조사 후 TTThumbsDataSource가 임 플레멘 테이션에 결코 부딪치지 않는 것처럼 보입니다. Three20 SDK의 하위 버전에서는이 동작을 테스트했지만 운이 없다. ( – user210504

답변

1

이며, 여기에이 질문을 찾을 수있는 사람들을위한 솔루션 TTPhoto 프로토콜의 photosource가 설정되어 있어야합니다.

id<TTPhoto> photo; 
photo.photoSource = self; 
관련 문제