0
我有一個速率按鈕。點擊該按鈕後,將打開包含5顆星的視圖。但是當我點擊特定單元格的速率按鈕時,特定視圖會打開,但其他單元格的某些視圖也會打開。我希望包含該特定視圖的5顆星的視圖才能被打開。IOS:如何防止視圖在所有單元格中打開
我附上了該視圖的代碼。
cv = [[ASStarRatingView alloc]initWithFrame:CGRectMake(190, y-5, 140, 30)]; //creat an instance of your custom view
cv.tag = indexPath.row ;
if([delegate.constants.snsrate[indexPath.row] isEqualToString: @"0"])
{
cv.hidden=TRUE;
}
else
{
cv.hidden=FALSE;
}
delegate.constants.selected=1;
[cell addSubview:cv];
而我的代碼關閉和打開視圖。
-(void)Rate_Comment:(UIButton *)sender
{
UIButton *b = (UIButton *)sender;
NSInteger row = b.tag ;
for(int i=0;i<[delegate.constants.snsrate count];i++)
delegate.constants.snsrate[i]= @"0";
delegate.constants.buttontag = row;
UITableViewCell *buttonCell = (UITableViewCell *)[b superview];
UITableView* table = (UITableView *)[buttonCell superview];
NSIndexPath* pathOfTheCell = [table indexPathForCell:buttonCell];
delegate.constants.snsIndexPath = pathOfTheCell;
if(![delegate.constants.user_id isEqualToString:[delegate.constants.snsCreatedBy objectAtIndex:row]])
{
if([[delegate.constants.snstotalrating_count objectAtIndex:row] isEqualToString:@"0"])
{
if(cv.hidden)
{
delegate.constants.snsrate[row]= @"1";
cv.hidden=FALSE;
}
else{
delegate.constants.snsrate[row]= @"0";
cv.hidden=TRUE;
}
[streamTable reloadRowsAtIndexPaths:@[pathOfTheCell] withRowAnimation:UITableViewRowAnimationNone];
}else
{
if(cv.hidden==FALSE)
cv.hidden=TRUE;
}
}
}
我是IOS新手。請任何人都可以幫助它將不勝感激。 預先感謝您。