I am using table view cell and adding a pop up view on clicking a button placed in cell .But when I am scrolling the table view view pop is disappearing from my cell. Here is my code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellF
orRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier =[NSString stringWithFormat:@"ArticleCell%d %d",indexPath.section,indexPath.row];
__block ArticleCell_iPad *cell = (ArticleCell_iPad *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[ArticleCell_iPad alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
[[NSBundle mainBundle] loadNibNamed:@"SynopsysViewSharing" owner:self options:nil];
cell = [[[ArticleCell_iPad alloc] initWithFrame:CGRectMake(0, 0, kCellWidth_iPad, kCellHeight_iPad)] autorelease];
__block NSDictionary *currentArticle = [self.articles objectAtIndex:indexPath.section];
[cell.iconImage loadImageWithURL:[[currentArticle objectForKey:@"sourceLogoImg"]objectForKey:@"text"]];
[cell.sideButton setBackgroundImage:[UIImage imageNamed:[cellButtonImageArr objectAtIndex:self.selectIndex]]
[cell.sideButton addTarget:self action:@selector(sideButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
cell.sideButton.tag = indexPath.section;
TableViewCellSelectionStyleNone;
}
return cell;
}
Button Action:
-(IBAction)sideButtonClicked:(UIButton*)sender
{
buttonShare=[[[NSBundle mainBundle] loadNibNamed:@"SynopsysViewSharing" owner:self options:nil] lastObject];
NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:sender.tag];
ArticleCell_iPad *cellSelected = (ArticleCell_iPad*)[_horizontalTableView cellForRowAtIndexPath:myIP];
[cellSelected.contentView addSubview:buttonShare];
buttonShare.alpha = 0.0f;
buttonShare.tag=500;
[buttonShare setFrame:CGRectMake(0,600, cellSelected.frame.size.height,55)];
[UIView animateWithDuration:0.5 animations:^{
[buttonShare setFrame:CGRectMake(0,cellSelected.frame.size.width-55, cellSelected.frame.size.height,55)];
buttonShare.alpha = 1.0f;
} completion:^(BOOL finished) {
}];
}