1

私はこのiPhone開発に不慣れです.私は今問題に悩まされています.私のアプリケーションでは、複数のラベルを表示するカバーフローが必要です.そのために、ビューのサブビューとして画像を追加し、ラベルを画像ビューのサブビュー。最初の7つの要素ではすべて正常に機能しますが、スクロールすると同じ要素が再び表示さ れます https://github.com/nicklockwood/iCarousel これを使用してカバーフローを達成しています

 - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index    reusingView:(ReflectionView *)view
{


UIImageView *imageView =nil;
UILabel *yourLabel=nil;
UILabel *yourLabel1=nil;
UILabel *yourLabel2=nil;
cardAvailableDataObject *singleCard=[self.cards objectAtIndex:index];

if (view == nil)
{
    //set up reflection view
    view = [[[ReflectionView alloc] initWithFrame:CGRectMake(0,0,200,self.view.frame.size.width/1.42)] autorelease];
    imageView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(0,0,200,self.view.frame.size.width/1.42)];
    [view addSubview:imageView];

    yourLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, -5, 200, 50)];
    yourLabel.textAlignment = UITextAlignmentCenter;


    [yourLabel setTextColor:[UIColor colorWithRed:(38/255.f) green:(171/255.f) blue:(226/255.f) alpha:1.0f]];  
    [yourLabel setBackgroundColor:[UIColor clearColor]];
    [yourLabel setFont:[UIFont fontWithName: @"Trebuchet MS" size: 17.0f]]; 
    [imageView addSubview:yourLabel];


    yourLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(90, 40, 300, 20)];


    [yourLabel1 setTextColor:[UIColor blackColor]];
    [yourLabel1 setBackgroundColor:[UIColor clearColor]];
    [yourLabel1 setFont:[UIFont fontWithName: @"Trebuchet MS" size: 12.0f]]; 
    [imageView addSubview:yourLabel1];




    yourLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(90, 61, 300, 20)];

    [yourLabel2 setTextColor:[UIColor blackColor]];
    [yourLabel2 setBackgroundColor:[UIColor clearColor]];
    [yourLabel2 setFont:[UIFont fontWithName: @"Trebuchet MS" size: 12.0f]]; 
    [imageView addSubview:yourLabel2];


}
else
{
    imageView = [[view subviews] lastObject];
    yourLabel = [[imageView subviews] lastObject];
    yourLabel1 = [[imageView subviews] lastObject];
    yourLabel2= [[imageView subviews] lastObject];
}



 yourLabel.text=singleCard.name; 

 yourLabel2.text=singleCard.companyname; 
 yourLabel1.text=singleCard.designation;
 imageView.image=[profile objectAtIndex:index];


return view;



  }

これは私のコードです。誰でもこれを解決する方法を提案できますか

4

0 に答える 0