Here I have a button in UITableViewCell. If I click button the another view should popup. If I click the same button then the view should be disable. Please help me out from this. Thanks in advance.
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CellIdentifier"];
cell.frame = CGRectZero;
cell.backgroundColor = [UIColor whiteColor];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 250, 50)];
label.font = [UIFont lightFontWithSize:14];
label.textAlignment = NSTextAlignmentLeft;
label.textColor = [UIColor blackColor];
label.highlightedTextColor = [UIColor whiteColor];
label.numberOfLines = 2;
label.tag = 1;
ForumDBFilePath* currObj = [forumResultArray objectAtIndex:indexPath.row];
cell.textLabel.text = [NSString stringWithFormat:@"%@",currObj.postcontent];
cell.textLabel.font = [UIFont regularFontWithSize:15];
[cell.contentView addSubview:label];
UIBackgroundButton* replyButton = [UIBackgroundButton buttonWithType:UIButtonTypeCustom];
[replyButton setButtonColor:[UIColor whiteColor] setBackgroundColor:[UIColor getNavBarColor]];
[replyButton setTitle:@"Reply" forState:UIControlStateNormal];
replyButton.tag = indexPath.row;
[replyButton.titleLabel setFont:[UIFont mediumFontWithSize:14]];
[replyButton setFrame:CGRectMake(viewWidth-0, 15, 125, 30)];
[replyButton addTarget:self action:@selector(replyButton:) forControlEvents:UIControlEventTouchUpInside];
[replyButton resignFirstResponder];
[cell.contentView addSubview:replyButton];
}
return cell;
}
You can override superview method like this:
- (id)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
id hitView = [super hitTest:point withEvent:event];
if (hitView == self) {
return nil;
} else {
return hitView;
}
}
Hope it helps you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.