我正在使用 aUITableView
来显示数据,并通过使用自定义按钮和删除功能,我试图删除选定的行。但是我想在该函数UITableView
为空时放置一个警报视图,并通过使用里面的按钮,UIAlertView
我试图根据条件导航到主页和上一页。但是它在UITableView
变空后崩溃了,我按下删除按钮并显示“程序接收信号:”SIGABRT“。
我的代码如下所示:
- (IBAction)DeleteButtonAction:(id)sender
{
DMSAppDelegate *d = (DMSAppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"Message From Custom Cell Received");
if(d->newtableData.count != 0)
{
NSIndexPath *indexPath = [self.tablevieww2 indexPathForCell:(UITableViewCell *)[[[sender superview] superview] superview]];
NSUInteger row = [indexPath row];
[d->newtableDataQt removeObjectAtIndex:row];
NSLog(@"data removed");
[self.tablevieww2 reloadData];
}
else
{
UIAlertView *alertview=[[UIAlertView alloc] initWithTitle:@"hello" message:@"Warning!!: Table is empty" delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:@"",@"No",nil];
textfieldQty1 = [alertview textFieldAtIndex:0];
textfieldQty1.keyboardType = UIKeyboardTypeNumberPad;
textfieldQty1.keyboardAppearance = UIKeyboardAppearanceAlert;
textfieldQty1.autocorrectionType = UITextAutocorrectionTypeNo;
[alertview show];
[alertview release];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
DMSViewController *bt=[[DMSViewController alloc]initWithNibName:nil bundle:nil];
bt.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:bt animated:YES];
}
else if (buttonIndex == 1)
{
NSString *newqty = [[NSString alloc] initWithFormat:@"%@",textfieldQty1.text];
DMSAppDelegate *d= (DMSAppDelegate *)[[UIApplication sharedApplication] delegate];
[d->newtableDataQt replaceObjectAtIndex:slCell1 withObject:(id)newqty];
NSLog(@"tb%@",d->newtableDataQt);
[self.tablevieww2 reloadData];
int total1=0;
for ( int i=0 ; i < [d->newtableDataQt count];++i )
{
NSString *string = [d->newtableDataQt objectAtIndex:i];
NSLog(@"string%@",string);
if ([string isEqualToString:@"0"])
{
}
else
{
NSLog(@"newArray%@",d->newtableDataPrice);
NSString *strP=[d->tableDataPrice objectAtIndex:i];
NSInteger sp=[strP integerValue];
NSInteger st=[string integerValue];
total1=total1+st*sp;
NSLog(@"total1%d",total1);
}
}
NSString *newtotal1=[NSString stringWithFormat:@"%d",total1];
DMSAppDelegate *d2 = (DMSAppDelegate *) [[UIApplication sharedApplication] delegate];
d2->totalD = [[NSString alloc] initWithString:newtotal1];
}
}
Please give me some solution. I am trying really hard from yesterday but not getting any success.
Thanks in advance.
@