2013-01-18 1 views
0

안녕하세요 저는 트위터를 표시하기 위해 내 응용 프로그램에서 회전 장치를 사용했습니다. 프로세스가의 ViewController 시간을 많이했다 만 표시 할, 그래서ICarousel보기 업데이트되지 않았습니다.

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view 
{ 
    if (!view) 
    { 
     //load new item view instance from nib 
     //control events are bound to view controller in nib file 
     view = [[[NSBundle mainBundle] loadNibNamed:@"Empty" owner:self options:nil] lastObject]; 

     //[self performSelectorInBackground:@selector(loadthetweets) withObject:nil ]; 
     //[self performSelectorInBackground:@selector(loadfromtheweb:) withObject:nil]; 
     //[self performSelectorOnMainThread:@selector(loadthetweets) withObject:nil waitUntilDone:YES]; 


     //[self performSelectorInBackground:@selector(loadthetweets) withObject:nil]; 
     /* 
     NSString *[email protected]"http://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=shoplog1&count=20"; 

     NSURL *feedURL =[NSURL URLWithString:feedname]; 

     //The JSON Part 
     NSData *data =[NSData dataWithContentsOfURL:feedURL]; 

     NSError* error; 
     _tweets= [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves 
                error:&error]; 



     maintext=[[_tweets objectAtIndex:index]objectForKey:@"text"]; 
     NSArray *piecesOfOriginalString = [maintext componentsSeparatedByString:@"http"]; 
     NSString *firstetxt=[piecesOfOriginalString objectAtIndex:0]; 
     NSLog(@"The first text: %@",firstetxt); 
     NSString *link=[@"http" stringByAppendingString:[piecesOfOriginalString objectAtIndex:1]]; 
     linktogo=[NSURL URLWithString:link]; 
     text.text=firstetxt; 

     NSLog(@"The link text: %@",link); 
     //NSDictionary *new =[[[tweets objectAtIndex:index]objectForKey:@"entities"]objectForKey:@"urls"]; 
     NSDictionary *retweeted=[[_tweets objectAtIndex:index]objectForKey:@"retweeted_status"]; 
     if (retweeted) { 
      NSString *urlll=[[[[_tweets objectAtIndex:index]objectForKey:@"retweeted_status"]objectForKey:@"user"]objectForKey:@"profile_image_url"]; 
      NSURL *iiii=[NSURL URLWithString:urlll]; 
      usericon.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:iiii]]; 
      username.text=[[[[_tweets objectAtIndex:index]objectForKey:@"retweeted_status"]objectForKey:@"user"]objectForKey:@"screen_name"]; 
     }else{ 
      [email protected]"Shoplog"; 
      usericon.image=[UIImage imageNamed:@"MyIcon copy_57.png"]; 
     } 
     */ 
     [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; 
     [Provideractivity startAnimating]; 
     [ContentActivity startAnimating]; 

     dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 

     dispatch_async(concurrentQueue, ^{ 

      [self loadthetweets]; 
      //[self loadfromtheweb:[NSNumber numberWithUnsignedInt:index ]]; 
      dispatch_async(dispatch_get_main_queue(), ^{ 
       //[self loadfromtheweb:[NSNumber numberWithUnsignedInt:index ]]; 
       maintext=[[_tweets objectAtIndex:index]objectForKey:@"text"]; 
       NSArray *piecesOfOriginalString = [maintext componentsSeparatedByString:@"http"]; 
       NSString *firstetxt=[piecesOfOriginalString objectAtIndex:0]; 
       NSLog(@"The first text: %@",firstetxt); 
       NSString *link=[@"http" stringByAppendingString:[piecesOfOriginalString objectAtIndex:1]]; 
       linktogo=[NSURL URLWithString:link]; 
       text.text=firstetxt; 

       NSLog(@"The link text: %@",link); 
       //NSDictionary *new =[[[tweets objectAtIndex:index]objectForKey:@"entities"]objectForKey:@"urls"]; 
       NSDictionary *retweeted=[[_tweets objectAtIndex:index]objectForKey:@"retweeted_status"]; 
       if (retweeted) { 
        NSString *urlll=[[[[_tweets objectAtIndex:index]objectForKey:@"retweeted_status"]objectForKey:@"user"]objectForKey:@"profile_image_url"]; 
        username.text=[[[[_tweets objectAtIndex:index]objectForKey:@"retweeted_status"]objectForKey:@"user"]objectForKey:@"screen_name"]; 
        NSURL *iiii=[NSURL URLWithString:urlll]; 
        usericon.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:iiii]]; 

       }else{ 
        [email protected]"Shoplog"; 
        usericon.image=[UIImage imageNamed:@"MyIcon copy_57.png"]; 
       } 

       [ContentActivity stopAnimating]; 
       [ContentActivity hidesWhenStopped]; 
       [Provideractivity stopAnimating]; 
       [Provideractivity hidesWhenStopped]; 



       [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; 
      }); 
     }); 



    } 
    return view; 

} 

은 무엇입니까 트윗을 다운로드 할 때 내가 업데이트 할 뷰 컨트롤러, 다음 회전 목마보기를로드 할 수 GDC를 사용했다 여기서 잘못 가고있는 것은 회전 목마의 11 번째 요소가 올바르게 업데이트되고 나머지는 비어 있으며 그 이유는 모르겠다는 것입니다.

누군가 도울 수 있습니까?

답변

0

블록에서 if (!view) {...} 블록은보기 만 만들고 구성하지 마십시오. 이 if 문 뒤 및 밖에서보기를 구성하십시오. - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view으로 전달 된보기는 이미 만들어져있을 수 있으며, 그렇다면 if 블록으로 들어 가지 않고 결코 구성되지 않기 때문에 짹짹이로드되지 않습니다.

0

답변 해 주셔서 감사합니다. , 비록 내가 그럭저럭 twitter를 다운로드 할 수 있었지만, (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view &보기 컨트롤러의 initfromnib 함수에서 호출한다. 지금 당장 시간이 덜 필요하다!