2014-07-18 12 views
-1

URL이 있습니다. 이제 Url.But에 대한 이미지를 가져올 수 있습니다. 이제 8 개의 이미지가 ScrollView.So에 전달되어야합니다. 내 문제에 대해 어떤 생각인지 알려주세요. 나는 다음과 같은 시도 : -UIScrollView에 이미지를 전달하는 방법

NSMutableArray *al=[NSJSONSerialization JSONObjectWithData:webData options:0 error:nil]; 
    for (NSDictionary *diction in al) 
    { 


     NSString *geting =[diction valueForKey:@"dealimage"]; 
     NSLog(@"dealimage is %@",geting); 

     NSData *getdata=[[NSData alloc]initWithData:[NSData dataFromBase64String:geting]]; 
     NSLog(@"good day %@",getdata); 
     dataimages=[UIImage imageWithData:getdata]; 
     NSLog(@"dataimages %@",dataimages); 

     [imagesarray addObject:dataimages]; 


    } 

내가 imagesarray 인쇄 할 때이

images array is array(
    "<UIImage: 0x7539b70>", 
    "<UIImage: 0x7176e00>", 
    "<UIImage: 0x7182960>", 
    "<UIImage: 0x7185d40>", 
    "<UIImage: 0x7541d00>", 
    "<UIImage: 0x7186e30>", 
    "<UIImage: 0x7186ff0>", 
    "<UIImage: 0x7187410>" 
) 

예를 나타내는 것 : - enter image description here 어떻게 내 얻는 이미지를 스크롤을 추가하는 방법을 가르쳐주세요. 고맙습니다.

+0

컬렉션보기를 사용합니다. – duci9y

+0

@ duci9y 고마워요하지만 이미지에 스크롤이 필요합니다 그래서 내게 이미지를 CollectionView.when 내가 CollectionView 셀 jest 표시에만 –

+0

컬렉션 이미지는 스크롤보기입니다 전달하는 방법에 대한 아이디어를 줘. 그것은 스크롤합니다. – duci9y

답변

0

이러한 이미지 각각을 UIScrollView의 하위보기로 추가하고 스크롤보기의 콘텐츠 크기를 결합 된 이미지의 총 너비로 설정해야합니다. 이것은 당신이 하나의 이미지를 위해 그것을하는 방법입니다.

UIImageView *image = [[UIImageView alloc] initWithImage:imagesarray[0]]; 
[scrollview addSubview:image]; 
scollview.contentSize = CGSizeMake(image.frame.size.height, image.frame.size.width); 

희망은 좋은 출발점이됩니다.

+0

답장을 보내 주셔서 감사합니다. –

+0

당신이 getScrollView = [[UIScrollView alloc] init]이라고 말한대로 시도해 보았습니다. UIImageView * imagescroll = [[UIImageView alloc] initWithImage : imagesarray [0]]; [gettingScrollView addSubview : imagescroll]; gettingScrollView.contentSize = CGSizeMake (100, 75); [self.view addSubview : gettingScrollView]; gettingScrollView.frame = CGRectMake (0, 0, 320, 80); imagesarray = [[NSMutableArray alloc] init]; gettingScrollView.backgroundColor = [UIColor yellowColor]; 그러나 나는 이미지를 얻지 못합니다. 도와주세요. –

+0

인덱스 뷰 0에 이미지를 추가 한 후에 이미지 배열을 다시 초기화하는 이유가 있습니까? – tomasbasham

관련 문제