ios - Cocos2D v3 CCTableView not scrolling -
i trying use cctableview in game. should able scroll through list of names. able click on cell , log cell clicked. when try scroll there no movement.
@interface wsmplayercandidatesubmenu(){ ccnodecolor *_candidatesubmenusprite; } @implementation wsmplayercandidatesubmenu - (void)onenter{ [super onenter]; cgsize winsize = [[ccdirector shareddirector] viewsize]; _candidatesubmenusprite.color = [cccolor whitecolor]; _candidatesubmenusprite.userinteractionenabled = no; self.candidatearray = [[wsmgamemanager sharedmanager] returncompany].candidates; cctableview *tblscores = [cctableview node]; tblscores.contentsize = cgsizemake(1.0,0.8); tblscores.anchorpoint = ccp(0.5f,0.375f); tblscores.positiontype = ccpositiontypenormalized; tblscores.position = _candidatesubmenusprite.position; tblscores.userinteractionenabled = yes; tblscores.datasource = self; tblscores.verticalscrollenabled = yes; tblscores.block = ^(cctableview *table){ nslog(@"cell %ld", (long)table.selectedrow); }; [_candidatesubmenusprite addchild:tblscores]; } -(cctableviewcell*)tableview:(cctableview *)tableview nodeforrowatindex:(nsuinteger)index{ cctableviewcell* cell = [cctableviewcell node]; cell.contentsizetype = ccsizetypemake(ccsizeunitnormalized, ccsizeunitpoints); cell.contentsize = cgsizemake(1, 40); // color every other row differently ccnodecolor* bg = [ccnodecolor nodewithcolor:[cccolor colorwithred:52/255.f green:73/255.f blue:94/255.f]]; bg.userinteractionenabled = no; bg.contentsizetype = ccsizetypenormalized; bg.contentsize = cgsizemake(1, 1); [cell addchild:bg]; wsmemployee *candidate = (wsmemployee*)[self.candidatearray objectatindex:index]; cclabelttf *lblcompanyname = [cclabelttf labelwithstring:candidate.name fontname:@"arialmt" fontsize:15.0f]; lblcompanyname.anchorpoint = ccp(1,0.5); //lblturnssurvived.string = @"1000"; lblcompanyname.positiontype = ccpositiontypenormalized; lblcompanyname.position = ccp(0.15,0.5); lblcompanyname.color = [cccolor colorwithred:242/255.f green:195/255.f blue:17/255.f]; [cell addchild:lblcompanyname]; return cell; } -(nsuinteger)tableviewnumberofrows:(cctableview *)tableview{ return [self.candidatearray count]; } -(float)tableview:(cctableview *)tableview heightforrowatindex:(nsuinteger)index{ return 40.f; }
you need set multipletouchenabled yes on instance of cctableview. had same problem , worked me.
Comments
Post a Comment