0
votes

In my code i was trying to set label in iCarouselView.My icarousel contains labels and textView so i am trying to set label but it is not setting properly.I have array of months and setting that array of months to each icarousel label, like this.

     (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
    {
       if (!view)
   {
         UIViewController * viewController = [self.storyboard  instantiateViewControllerWithIdentifier:@"PopUpView"];
    view = [viewController.view viewWithTag:999];
     UILabel *label=(UILabel*)[viewController.view viewWithTag:109];
   label.text = [_monthsArray objectAtIndex:index];
   CGRect  Frame = CGRectMake(view.frame.origin.x, view.frame.origin.y+100, view.frame.size.width, view.frame.size.height);
    view.frame = Frame;
}
return view;}

I am loading external view as popUpView in storyBoard and getting label using tag. And i am returning carousel count as [monthsArray count]. carousel delegate and datasource is also set and reloadData method is also called on iCarousel.

The output which i am getting is something like this.

| January,February,March,November,December|

Please tell me where i am wrong?and what to do now?

1
iCaurosel delegate will take a view.nswamy

1 Answers

0
votes

Update you code to below one -

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
    if (!view){
        UIViewController * viewController = [self.storyboard  instantiateViewControllerWithIdentifier:@"PopUpView"];
        view = [viewController.view viewWithTag:999];
        CGRect  Frame = CGRectMake(view.frame.origin.x, view.frame.origin.y+100, view.frame.size.width, view.frame.size.height);
        view.frame = Frame;
    }

    UILabel *label=(UILabel*)[view viewWithTag:109];
    label.text = [_monthsArray objectAtIndex:index];

    return view;
}

iCaurosel will take UIView, In your case you are creating a view controller, which is not retained and is dangerous. See if you change it to view via a custom Xib.