UIButton *vote = [UIButton buttonWithType:UIButtonTypeCustom];
vote.frame = CGRectMake(250,cell.frame.size.height/2,60,30);
UIImage *img2 = [UIImage imageNamed:@"voteBt.png"];
vote.tag = [obj.contentID intValue];
// vote.tag=obj.contentID;
vote.frame = CGRectMake(250,cell.frame.size.height/2,60,30);
UIImage *img2 = [UIImage imageNamed:@"voteBt.png"];
vote.tag = [obj.contentID intValue];
// vote.tag=obj.contentID;
contentID是字符串类型,tag是int. contentID值如果是"12345",那么直接赋值后,tag就会是完全不同的值(对应的ascll值)
所以应该用intValue来转换。最好的方法是重写button,添加一个字符串变量用来赋值,tag仅仅应该用来存数据