Search code examples
iphoneios5uiviewios4icarousel

My Custom UIView Show but nothing inside it when using iCarousel?


I'm Using iCarousel to show my Custom UIView in CoverFlow Mode but when i run my app it is show up but nothing inside it , it is like not the view i add ??? so can u help me ???

 - (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


Solution

  • Some thinks you could check :

    • Did you implement iCarouselDelegate and iCarouselDataSource ?

    • Did you set the carousel's delegates ex. myCarousel.delegate = self; myCarousel.dataSource = self;

    • Did you add the carousel's view to the view stack ex. [myView.view addSubview:myCarousel];

    You should also implement the following delegate method

    • (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel