ios - Three20 TTPhotoViewController is not displaying photos -
i have gone through few tutorials including sample app included three20 , cannot figure out why photos aren't showing in ttphotoviewcontroller. find pretty hard debug. below code have. thoughts on why images not load , how debug great. black view in between bottom tabbar , upper nav bar. see left , right arrows overlayed on black view seems navigating photos although thought supposed display thumbnail gallery.
// 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 // 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 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 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 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]; (int = 0; < _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 // 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
you may find answer here: http://www.raywenderlich.com/1430/how-to-use-the-three20-photo-viewer
Comments
Post a Comment