-1

应用程序崩溃。

我添加了自定义单元格。当滚动应用程序崩溃并出现错误时:

“UIView setTableViewStyle 无法识别的选择器发送到实例 XXXXXX”

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    if(tableView==tableviewDetail)
    {
        static NSString *CellIdentifier_1 = @"Cell";
        CustomCASADetailCell *cell = (CustomCASADetailCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier_1];

          if (cell == nil)
        {

           NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCASADetailCell" owner:self options:nil];

            cell = [topLevelObjects objectAtIndex:0];


            if([strCallingView isEqualToString:@"CreditCard"])
            {
                if ([indexPath row] % 2==0)
                    cell.contentView.backgroundColor=[UIColor whiteColor] ;
                else
                    cell.contentView.backgroundColor =[UIColor colorWithRed:205.0f/255.0f green:201.0f/255.0f blue:201.0f/255.0f alpha:0.6f];
            }
            else
            {
                if ([indexPath row] % 2==0)
                    cell.contentView.backgroundColor=[UIColor whiteColor] ;
                else
                    cell.contentView.backgroundColor =[UIColor colorWithRed:255.0f/255.0f green:239.0f/255.0f blue:213.0f/255.0f alpha:0.6f];
            }

        }

        NSArray *toplavelobject=[[NSBundle mainBundle]loadNibNamed:@"CustomCASADetailCell" owner:self options:nil];
        for(id c in toplavelobject)
        {
            if ([c isKindOfClass:[UITableViewCell class]])
            {
                cell=(CustomCASADetailCell *) c;

                break;
            }
        }

        if([strCallingView isEqualToString:@"CreditCard"])
        {
            if([maCreditCardDetailKey count]>0 && [maCreditCardDetailValue count]>0)
            {
                cell.lblName.text=[maCreditCardDetailKey objectAtIndex:indexPath.row];
                cell.lblDescription.text=[maCreditCardDetailValue objectAtIndex:indexPath.row ];
            }

        }
        else if([strCallingView isEqualToString:@"Account"])
        {
            if([maAccountDetailKey count]>0 && [maAccountDetailValue count]>0)
            {
                cell.lblName.text=[maAccountDetailKey objectAtIndex:indexPath.row];
                cell.lblDescription.text=[maAccountDetailValue objectAtIndex:indexPath.row ];
            }

        }
        return cell;
    }

        else if(tableView==tableviewMiniStatement)
    {
        static NSString *CellIdentifier_2 = @"Cell";

       MinistatementTableCell *cell = (MinistatementTableCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier_2];

        if (cell == nil)
        {

         cell = [[MinistatementTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] ;

            NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MinistatementTableCell" owner:self options:nil];

            cell = [topLevelObjects objectAtIndex:0];

        }

        cell.lblDescription.adjustsFontSizeToFitWidth=NO;
        cell.lblDescription.numberOfLines=4;
        cell.lblDescription.lineBreakMode=UILineBreakModeWordWrap;

       MiniStatement *objMiniStatement=[[MiniStatement alloc]init];
       if([marrAccountMinistatement count]>0)
       {

           if (tableView.tag==0)


           {
                objMiniStatement=[marrAccountMinistatement objectAtIndex:indexPath.row];

           }
        else
            {
               objMiniStatement=[marrAccountMinistatement objectAtIndex:((tableView.tag*5)+indexPath.row)];
            }

                cell.lblTransactionDate.text=objMiniStatement.strATAccountPostDate;//set transaction date here

                cell.lblValueDate.text=objMiniStatement.strATAccountPostDate ;

                cell.lblDescription.text=objMiniStatement.strATNaration;


                cell.lblAmount.text=[NSString stringWithFormat:@"%@  %@",lblCurrency.text,objMiniStatement.strATTransactionAmount];


            }
      }

        return cell;

    }



    else if(tableView==tableviewCCUnbilledTransaction)
    {
        static NSString *CellIdentifier_3 = @"Cell";
        CCUnbilledTransactionCell *cell = (CCUnbilledTransactionCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier_3];

        if (cell == nil)
        {



            NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CCUnbilledTransactionCell" owner:self options:nil];

            cell = [topLevelObjects objectAtIndex:0];

        }


        NSArray *toplavelobject=[[NSBundle mainBundle]loadNibNamed:@"CCUnbilledTransactionCell" owner:self options:nil];
        for(id c in toplavelobject)
        {
            if ([c isKindOfClass:[UITableViewCell class]])
            {
                cell=(CCUnbilledTransactionCell *) c;

                break;
            }
        }

        cell.lblDescription.adjustsFontSizeToFitWidth=NO;
        cell.lblDescription.numberOfLines=4;
        cell.lblDescription.lineBreakMode=UILineBreakModeWordWrap;

        CardMiniStatement *objCardMiniStatement=[[CardMiniStatement alloc]init];
        if([marrCCUnbilledTransactionRecordShown count]>0)
        {
            if (tableView.tag==0)
            {
                objCardMiniStatement=[marrCCUnbilledTransactionRecordShown objectAtIndex:indexPath.row];
            }
            else
            {
                objCardMiniStatement=[marrCCUnbilledTransactionRecordShown objectAtIndex:((tableView.tag*5)+indexPath.row)];//Sarita 28May
                          }
            if(objCardMiniStatement!=nil)
            {
                cell.lblCreditCardNo.text=[FormatData FormatCreditCardNumber:objCardMiniStatement.strCardNumber];

                cell.lblTransactionDate.text=objCardMiniStatement.strTransactionDate ;
                cell.lblPostDate.text=objCardMiniStatement.strPostDate;
                cell.lblDescription.text=objCardMiniStatement.strTransactionDetail;
                cell.lblAmount.text=objCardMiniStatement.strTransactionAmount;
            }
        }

        return cell;
    }



}
4

2 回答 2

0

您也可以使用abort();.

于 2013-06-27T06:04:34.797 回答
0

问:如何以编程方式退出我的 iOS 应用程序?

答:没有提供优雅终止 iOS 应用程序的 API。

在 iOS 中,用户按下 Home 按钮来关闭应用程序。如果您的应用程序存在无法提供其预期功能的情况,推荐的方法是向用户显示警报,指出问题的性质以及用户可能采取的措施——打开 WiFi、启用定位服务等。允许用户自行决定终止应用程序。

警告:不要调用退出函数。调用 exit 的应用程序将在用户看来已经崩溃,而不是执行正常终止并动画返回主屏幕。此外,可能不会保存数据,因为如果您调用 exit,将不会调用 -applicationWillTerminate: 和类似的 UIApplicationDelegate 方法。

如果在开发或测试期间需要终止您的应用程序,建议使用中止函数或断言宏。

来源:iOS 开发者库技术问答 QA1561

于 2013-06-27T05:27:47.107 回答