This function gets executed
but This function is not getting called.... and the minus (-) button doesn't appears
Code:
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPat
but This function is not getting called.... and the minus (-) button doesn't appears
Code:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
Code:
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
[super loadView];
tblSelectedSupplier = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
//allocate the view
self.view = tblSelectedSupplier;
tblSelectedSupplier.delegate = self;
tblSelectedSupplier.dataSource = self;
//Set the title
self.navigationItem.title = @"Selected Supplier";
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStyleBordered target:self action:@selector(save_selSupplier:)]autorelease];
[self setEditing:YES animated:YES];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"will appear contacts");
[tblSelectedSupplier reloadData];
}
-(IBAction)save_selSupplier:(id)sender{
}
#pragma mark Table view methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [selectedSuppList count];
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
NSLog(@"Self edititng");
}
// Update array of displayed objects by inserting/removing objects as necessary.
//
- (void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// Animate deletion
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
[tblSelectedSupplier deleteRowsAtIndexPaths:indexPaths
withRowAnimation:UITableViewRowAnimationFade];
}
}
//exclude rows from being edited
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"table view canEditRowAtIndexPath");
return YES;
}
//editing sytle
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"Self edititng Insert");
return UITableViewCellEditingStyleDelete;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
UIFont *titleFont = [UIFont fontWithName:@"Helvetica" size:14.0];
[[cell textLabel] setFont:titleFont];
}
KeyValue *keyval = [selectedSuppList objectAtIndex:indexPath.row];//[[Dictionary getarrySelSupplier] objectAtIndex:0];
//[supplierlist objectAtIndex:indexPath.row];
cell.textLabel.text = keyval._value;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"didSelectRowAtIndexPath");
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 45;
}