0

我正在使用 iCarousel 在 CoverFlow 模式下显示我的自定义 UIView 但是当我运行我的应用程序时它会显示但里面什么都没有,就像不是我添加的视图???那你能帮我吗???

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



    CustomView *temp;
    if (view == nil)
    {
        //don't do anything specific to the index within
        //this `if (view == nil) {...}` statement because the view will be
        //recycled and used with other index values later
        view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 315.0f, 350.0f)] autorelease];
        temp=[[CustomView alloc] initWithFrame:view.bounds];

        temp.backgroundColor=[UIColor redColor];
        view.contentMode = UIViewContentModeCenter;


        temp.tag=1;
        [view addSubview:temp];
    }
    else
    {
        //get a reference to the label in the recycled view
        temp = (CustomView *)[view viewWithTag:1];
    }

    //set item label
    //remember to always set any properties of your carousel item
    //views outside of the `if (view == nil) {...}` check otherwise
    //you'll get weird issues with carousel item content appearing
    //in the wrong place in the carousel
    //label.text = [[items objectAtIndex:index] stringValue];

    return view;
}

在此处输入图像描述 在此处输入图像描述

4

1 回答 1

2

有些人认为你可以检查:

  • 你实现了 iCarouselDelegate 和 iCarouselDataSource 吗?

  • 您是否设置了轮播的代表前。myCarousel.delegate = 自我;myCarousel.dataSource = 自我;

  • 您是否将轮播视图添加到视图堆栈前。[myView.view addSubview:myCarousel];

您还应该实现以下委托方法

  • (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
于 2012-10-15T11:50:21.397 回答