tableview - Action for button in cell - Objective C -
i'm beginner in objective-c. have problem. have tableview 20 cells, has "name" , "button" each cell. want when click button in cell, button changed background image. don't know why, when click button in cell #1 change background button in cell #8 auto change background. have idea? please me.
-(void)clicklike:(uibutton*)sender { uiimage *curimg = sender.currentimage; uiimage *like = [uiimage imagenamed:@"like.png"]; uiimage *dislike = [uiimage imagenamed:@"dislike.png"]; if(curimg==like){ [sender setimage:[uiimage imagenamed:@"dislike.png"] forstate:uicontrolstatenormal]; sender.selected = true; //insert dislike song songobject *list = [self.arrsong objectatindex:sender.tag]; iduser=@"1"; idsong=list.idsong; [self dislikesong:idsong and:iduser]; } else if(curimg==dislike){ [sender setimage:[uiimage imagenamed:@"like.png"] forstate:uicontrolstatenormal]; sender.selected = true; //insert song songobject *list = [self.arrsong objectatindex:sender.tag]; iduser=@"1"; idsong=list.idsong; [self likesong:idsong and:iduser]; } }
button in cell #1 , button in cell #8 same uibutton object, problem not in method. must have 2 button pointed 1 uibutton object. check code button #1 , button #8 created.
Comments
Post a Comment