У меня есть кнопка курса. При нажатии на эту кнопку открывается вид, содержащий 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. Пожалуйста, если кто-то может помочь, он будет очень признателен. Спасибо заранее.