- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(250, 50, 49, 19);
//[button setBackgroundColor:[UIColor clearColor]];
UIImage *buttonImage = [UIImage imageNamed:@"DoneN.png"];
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
[button addTarget:self action:@selector(del:)forControlEvents:UIControlEventTouchUpInside];
button.tag = indexPath.row;
[cell.contentView addSubview:button];
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.frame = CGRectMake(250, 15, 50, 20);
[button1 setBackgroundColor:[UIColor clearColor]];
UIImage *buttonImage1 = [UIImage imageNamed:@"edit.png"];
[button1 setBackgroundImage:buttonImage1 forState:UIControlStateNormal];
[button1 addTarget:self action:@selector(edit:)forControlEvents:UIControlEventTouchUpInside];
button1.tag = indexPath.row;
[cell.contentView addSubview:button1];
// Configure the cell.
cell.textLabel.text= [nameArray objectAtIndex:indexPath.row];
cell.detailTextLabel.text=[placeArray objectAtIndex:indexPath.row];
return cell;
}
-(void)del:(id)sender
{
UIButton *tappedButton = (UIButton*)sender;
q=tappedButton.tag;
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Are you sure to delete this Data?" message:nil delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"Don't Allow", nil];
[alert show];
}
-(void)edit:(id)sender{
UIButton *tappedButton = (UIButton*)sender;
q=tappedButton.tag;
NSString *index=[NSString stringWithFormat:@"%d",q];
[currentDefaults setObject:index forKey:@"edit"];
[self.navigationController popViewControllerAnimated:YES];
}
No comments:
Post a Comment