我的自定义UIView显示但在使用iCarousel时没有任何内容?

时间:2012-10-15 11:40:12

标签: iphone ios5 uiview ios4 icarousel

我正在使用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;
}

enter image description here enter image description here

1 个答案:

答案 0 :(得分:2)

有些人认为你可以查一下:

  • 您是否实施了iCarouselDelegate和iCarouselDataSource?

  • 您是否设置了旋转木马的代表 恩。 myCarousel.delegate = self; myCarousel.dataSource = self;

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

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

  • (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel