{"action":"created","issue":{"url":"https://api.github.com/repos/nicklockwood/iCarousel/issues/564","labels_url":"https://api.github.com/repos/nicklockwood/iCarousel/issues/564/labels{/name}","comments_url":"https://api.github.com/repos/nicklockwood/iCarousel/issues/564/comments","events_url":"https://api.github.com/repos/nicklockwood/iCarousel/issues/564/events","html_url":"https://github.com/nicklockwood/iCarousel/issues/564","id":54184256,"number":564,"title":"Wrong current item index when reusing view and more than 10 items in carousel","user":{"login":"gopaldevra","id":6728281,"avatar_url":"https://avatars.githubusercontent.com/u/6728281?v=3","gravatar_id":"","url":"https://api.github.com/users/gopaldevra","html_url":"https://github.com/gopaldevra","followers_url":"https://api.github.com/users/gopaldevra/followers","following_url":"https://api.github.com/users/gopaldevra/following{/other_user}","gists_url":"https://api.github.com/users/gopaldevra/gists{/gist_id}","starred_url":"https://api.github.com/users/gopaldevra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gopaldevra/subscriptions","organizations_url":"https://api.github.com/users/gopaldevra/orgs","repos_url":"https://api.github.com/users/gopaldevra/repos","events_url":"https://api.github.com/users/gopaldevra/events{/privacy}","received_events_url":"https://api.github.com/users/gopaldevra/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-13T12:03:41Z","updated_at":"2015-01-14T07:12:26Z","closed_at":null,"body":"I am using carousel type rotary , and i have array of custom objects around 14 and i need to refresh another view according to centered carousel item , for this i'm using currentItemIndex property of carousel. Sometimes it is not working as expected. It gives me wrong currentItemIndex."},"comment":{"url":"https://api.github.com/repos/nicklockwood/iCarousel/issues/comments/69877577","html_url":"https://github.com/nicklockwood/iCarousel/issues/564#issuecomment-69877577","issue_url":"https://api.github.com/repos/nicklockwood/iCarousel/issues/564","id":69877577,"user":{"login":"gopaldevra","id":6728281,"avatar_url":"https://avatars.githubusercontent.com/u/6728281?v=3","gravatar_id":"","url":"https://api.github.com/users/gopaldevra","html_url":"https://github.com/gopaldevra","followers_url":"https://api.github.com/users/gopaldevra/followers","following_url":"https://api.github.com/users/gopaldevra/following{/other_user}","gists_url":"https://api.github.com/users/gopaldevra/gists{/gist_id}","starred_url":"https://api.github.com/users/gopaldevra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gopaldevra/subscriptions","organizations_url":"https://api.github.com/users/gopaldevra/orgs","repos_url":"https://api.github.com/users/gopaldevra/repos","events_url":"https://api.github.com/users/gopaldevra/events{/privacy}","received_events_url":"https://api.github.com/users/gopaldevra/received_events","type":"User","site_admin":false},"created_at":"2015-01-14T07:12:26Z","updated_at":"2015-01-14T07:12:26Z","body":"This method is as\r\n\r\n\r\n- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIImageView *)view\r\n{\r\n    UILabel *label = nil;\r\n    ChannelInfoModal *channel = self.arrayOfCarouselElements[index] ;\r\n    \r\n    \r\n    //create new view if no view is available for recycling\r\n    \r\n//    if (view == nil)\r\n//    {\r\n//        \r\n    \r\n        if ( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {\r\n            \r\n            view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 80.0f, 80.0f)];\r\n            view.backgroundColor = [UIColor colorWithRed:242.0/255.0 green:242.0/255.0 blue:242.0/255.0 alpha:1];\r\n            \r\n            UIImageView *imgView = [[UIImageView alloc]init];\r\n            imgView.frame = CGRectMake((view.frame.size.width/2)-35, (view.frame.size.height/2)-35, 70, 50);\r\n            \r\n            [view addSubview:imgView];\r\n            \r\n            UILabel *lblChannelNumber = [[UILabel alloc]init];\r\n            lblChannelNumber.frame = CGRectMake(\r\n                                                \r\n                                                (view.frame.size.width/2)-35,\r\n                                                \r\n                                                imgView.frame.origin.y+imgView.frame.size.height,\r\n                                                \r\n                                                70,\r\n                                                \r\n                                                20);\r\n            \r\n            \r\n            [lblChannelNumber setText:channel.channelNumber];\r\n            \r\n            [lblChannelNumber setTextColor:kColor_BlueTheme_TextToNearBlack] ;\r\n            [lblChannelNumber setFont:[UIFont fontWithName:kFontHelveticaNeueRegular size:12]];\r\n            lblChannelNumber.backgroundColor = kColor_BlueTheme_TextToNearWhite;\r\n            [lblChannelNumber setTextAlignment:NSTextAlignmentCenter];\r\n            [view addSubview:lblChannelNumber];\r\n            \r\n            \r\n            \r\n            \r\n            \r\n            NSString *ChannelName = [NSString stringWithFormat:@\"%@\",channel.channelName];\r\n            \r\n            UIImage *imageChannel = [UIImage imageNamed:ChannelName];\r\n            [imgView setImage:imageChannel];\r\n            \r\n            view.contentMode = UIViewContentModeScaleAspectFit;\r\n            \r\n            \r\n            \r\n            label = [[UILabel alloc]initWithFrame:view.bounds];\r\n            label.numberOfLines = 0;\r\n            //label.lineBreakMode = NSLineBreakByCharWrapping;\r\n            label.backgroundColor = [UIColor clearColor];\r\n            \r\n            if (SYSTEM_VERSION_LESS_THAN(@\"6.0\")) {\r\n                label.textAlignment = UITextAlignmentCenter;\r\n            }\r\n            \r\n            if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@\"7.0\")) {\r\n                label.textAlignment = NSTextAlignmentCenter;\r\n            }\r\n            \r\n            else\r\n            {\r\n                label.textAlignment = NSTextAlignmentCenter;\r\n            }\r\n            \r\n            // label.font = [label.font fontWithSize:10];\r\n            [label setFont:[UIFont fontWithName:kFontHelveticaNeueBold size:1]];\r\n            label.tag = 1;\r\n            view.layer.borderColor = [UIColor lightGrayColor].CGColor;\r\n            [view.layer setCornerRadius:5.0f];\r\n            view.layer.borderWidth = 1.0f;\r\n            label.layer.borderColor = [UIColor lightGrayColor].CGColor;\r\n            [label.layer setCornerRadius:5.0f];\r\n            label.layer.borderWidth = 1.0f;\r\n            [view setClipsToBounds:YES];\r\n            \r\n            \r\n            [view addSubview:label];\r\n            \r\n        }\r\n        \r\n        \r\n        else\r\n        {\r\n            \r\n            view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 170.0f, 170.0f)];\r\n            view.backgroundColor = [UIColor colorWithRed:242.0/255.0 green:242.0/255.0 blue:242.0/255.0 alpha:1];\r\n            \r\n            UIImageView *imgView = [[UIImageView alloc]init];\r\n            imgView.frame = CGRectMake((view.frame.size.width/2)-80, (view.frame.size.height/2)-55, 160, 110);\r\n            \r\n            [view addSubview:imgView];\r\n            \r\n            \r\n            UILabel *lblChannelNumber = [[UILabel alloc]init];\r\n            lblChannelNumber.frame = CGRectMake(\r\n                                                \r\n                                                (view.frame.size.width/2)-80,\r\n                                                \r\n                                                imgView.frame.origin.y+imgView.frame.size.height,\r\n                                                \r\n                                                160,\r\n                                                \r\n                                                40);\r\n            \r\n            \r\n            [lblChannelNumber setText:channel.channelNumber];\r\n            \r\n            [lblChannelNumber setTextColor:kColor_BlueTheme_TextToNearBlack] ;\r\n            [lblChannelNumber setFont:[UIFont fontWithName:kFontHelveticaNeueRegular size:12]];\r\n            lblChannelNumber.backgroundColor = kColor_BlueTheme_TextToNearWhite;\r\n            [lblChannelNumber setTextAlignment:NSTextAlignmentCenter];\r\n            [view addSubview:lblChannelNumber];\r\n            \r\n            \r\n            \r\n            NSString *ChannelName = [NSString stringWithFormat:@\"%@\",channel.channelName];\r\n            \r\n            UIImage *imageChannel = [UIImage imageNamed:ChannelName];\r\n            [imgView setImage:imageChannel];\r\n            \r\n            view.contentMode = UIViewContentModeScaleAspectFit;\r\n            \r\n            \r\n            label = [[UILabel alloc]initWithFrame:view.bounds];\r\n            label.numberOfLines = 0;\r\n            label.backgroundColor = [UIColor clearColor];\r\n            \r\n            if (SYSTEM_VERSION_LESS_THAN(@\"6.0\")) {\r\n                label.textAlignment = UITextAlignmentCenter;\r\n            }\r\n            \r\n            if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@\"7.0\")) {\r\n                label.textAlignment = NSTextAlignmentCenter;\r\n            }\r\n            \r\n            else\r\n            {\r\n                label.textAlignment = NSTextAlignmentCenter;\r\n            }\r\n            \r\n            label.font = [label.font fontWithSize:32.0f];\r\n            label.tag = 1;\r\n            view.layer.borderColor = [UIColor lightGrayColor].CGColor;\r\n            [view.layer setCornerRadius:5.0f];\r\n            view.layer.borderWidth = 1.0f;\r\n            label.layer.borderColor = [UIColor lightGrayColor].CGColor;\r\n            [label.layer setCornerRadius:5.0f];\r\n            label.layer.borderWidth = 1.0f;\r\n            [view setClipsToBounds:YES];\r\n            \r\n            \r\n            [view addSubview:label];\r\n            \r\n            \r\n        }\r\n   // }\r\n//    else\r\n//    {\r\n//        //get a reference to the label in the recycled view\r\n//        label = (UILabel *)[view viewWithTag:1];\r\n//    }\r\n    \r\n    \r\n    label.font = [UIFont fontWithName:kFontHelveticaNeueRegular size:16];\r\n    //ChannelInfoModal *channel = self.arrayOfCarouselElements[index] ;\r\n    // label.text = channel.channelName;\r\n    \r\n    return view;\r\n}\r\n"}}