I have created the below code to display buttons in UITableView. I want to add click event for every particular cell in table to reach to google links by clicking into that button.
How to add to clicking events into the buttons options for particular cell and to reach google link?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UIButton *button =[[UIButton alloc]initWithFrame:CGRectMake(5,5,40,40)];
[button addTarget:self action:@selector(buttonpressed:) forControlEvents:UIControlEventTouchUpInside];
[button setImage:[UIImage imageNamed:@"lori"] forState:UIControlStateNormal];
[button setTag:9001];
[cell addSubview:button];
[cell setIndentationWidth:45];
[cell setIndentationLevel:1];
cell.textLabel.text = [thearray objectAtIndex:indexPath.row];
return cell;
}
-(void) buttonpressed:(UIButton *)sender {}
Try something like:
this will open safari pointing to the URL you pass in.
If you do not want to open safari, then you should display your own
UIWebView.Furthermore, you might want to add your button to
contentView: