2012-01-06 2 views
0

이 응용 프로그램의 온라인 이미지 갤러리를 만들 때이 API을 사용하고 있습니다.하지만 문제는 샘플 코드에서이 코드를 사용하여 동적 갤러리를 만들면 flickr의 몇 가지 이미지 만 보여줍니다. 예를 들어iOS : KTPhotoBrowserDataSource에 대한 동적 URL 생성

: 여기에 URL에서 이미지는 코드 www.mysite.com/gallery

그리고이 URL에 많은 사진이있다!

- (id)init { 
    self = [super init]; 
    if (self) { 
     // Create a 2-dimensional array. First element of 
     // the sub-array is the full size image URL and 
     // the second element is the thumbnail URL. 
     images_ = [[NSArray alloc] initWithObjects: 

       [NSArray arrayWithObjects:@"http://farm5.static.flickr.com/4001/4439826859_19ba9a6cfa_o.jpg", @"http://farm5.static.flickr.com/4001/4439826859_4215c01a16_s.jpg", nil], 

       [NSArray arrayWithObjects:@"http://farm4.static.flickr.com/3427/3192205971_0f494a3da2_o.jpg", @"http://http://farm4.static.flickr.com/3427/3192205971_0f494a3da2_o.jpg" , nil]; 
    } 
    return self; 
} 

#pragma mark - 
#pragma mark KTPhotoBrowserDataSource 

- (NSInteger)numberOfPhotos { 
    NSInteger count = [images_ count]; 
    return count; 
} 

- (void)imageAtIndex:(NSInteger)index photoView:(KTPhotoView *)photoView { 
    NSArray *imageUrls = [images_ objectAtIndex:index]; 
    NSString *url = [imageUrls objectAtIndex:FULL_SIZE_INDEX]; 
    [photoView setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"photoDefault.png"]]; 
} 

- (void)thumbImageAtIndex:(NSInteger)index thumbView:(KTThumbView *)thumbView { 
    NSArray *imageUrls = [images_ objectAtIndex:index]; 
    NSString *url = [imageUrls objectAtIndex:THUMBNAIL_INDEX]; 
    [thumbView setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"photoDefault.png"]]; 
} 
+0

질문의 끝 부분을 잃어버린 것처럼 보입니다. 또한,이 대신 여기에 있어야합니다. 그것을 닫기 위해 투표하지만, 당신이 질문을 끝내면 멋진 모드가 당신을 위해 질문을 이동시킬 것입니다. – DKnight

+0

미안하지만 "나"는 실수 였어. –

답변

0

갤러리 웹 사이트가 json 또는 xml을 반환합니까? 그렇지 않으면 갤러리 웹 사이트에서 반환 된 HTML을 읽고 이미지 태그를 검색해야합니다. http://github.com/topfunky/hpple/tree/master 또는 http://github.com/zootreeves/Objective-C-HMTL-Parser을 사용하여 HTML을 구문 분석 할 수 있습니다. 간단한 HTML의 경우이 방법이 효과적입니다.

HTML이 복잡한 경우 갤러리 웹 사이트 YQL to scrape을 사용하고 JSON으로 변환하십시오.