ICarousel is not displayed and the method is not processed

I am trying to achieve the right to the iCarousel object from right to left on both sides.

So, I imported the GtiHub project into My application, assigned the UIView iCarousel ... Associated this with IBOutLet on my MainViewController and passed the delegate as well as the DataSource as a UITableViewController.

Although it will not appear, and I'm not sure what might cause this problem.

My iCarousel DataSource are NSMutableArray * elements; Designed like this:

for (int i = 0; i < 100; i++)
{
    [_items addObject:@(i)];
}

I initialize iCarousel in ViewDidLoad as shown below

- (void)viewDidLoad
{
  [super viewDidLoad];
  //Initialize Carousel
  _carousel = [[iCarousel alloc] init];
  _carousel.delegate = self;
  _carousel.dataSource = self;

  //Carousel Testing Data
  for (int i = 0; i < 100; i++)
  {
     [_items addObject:@(i)];
  }

  //configure carousel
  _carousel.type = iCarouselTypeRotary;

}

My methods for carousel are below:

#pragma mark -
#pragma mark iCarousel methods

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
   //return the total number of items in the carousel
   return [_items count];
}

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
   UILabel *label = nil;

   //create new view if no view is available for recycling
   if (view == nil)
   {
      view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)];
      ((UIImageView *)view).image = [UIImage imageNamed:@"page.png"];
      view.contentMode = UIViewContentModeCenter;

      label = [[UILabel alloc] initWithFrame:view.bounds];
      label.backgroundColor = [UIColor clearColor];
      label.font = [label.font fontWithSize:50];
      label.tag = 1;
      [view addSubview:label];
   }
  else
   {
      //get a reference to the label in the recycled view
      label = (UILabel *)[view viewWithTag:1];
   }


  label.text = [_items[index] stringValue];
  return view;
}

 - (CGFloat)carousel:(iCarousel *)carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value
 {
    switch (option)
    {
       case iCarouselOptionFadeMin:
           return -0.2;
       case iCarouselOptionFadeMax:
           return 0.2;
       case iCarouselOptionFadeRange:
           return 2.0;
       default:
           return value;
     }
  }

Everything related to the storyboard seems to be related and the data should represent itself, what is wrong and how can I fix this problem?

+4
4

DataSource (_items) :

  • , IBOutlet , "" " ", ( ).

  • _carousel.delegate _carousel.dataSource dataSource ( - _items).

+6

, , iCarousel Datasource Delegate. , , iCarousel :

    @interface yourViewController : UIViewController <iCarouselDataSource, iCarouselDelegate>

,

   #import "iCarousel.h"
0

: DidLoad

  _carousel = [[iCarousel alloc] init];

it looks like you forgot to set the frame for _carousel and add it as a subspecies.

0
source

To get a link to an image, try the following:

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)];
imageView.image = [UIImage imageNamed:@"page.png"];
view = imageView;
0
source

All Articles