-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

Q: プログラムで iOS アプリケーションを終了するにはどうすればよいですか?

A: iOS アプリケーションを正常に終了するための API は提供されていません。

iOS では、ユーザーはホーム ボタンを押してアプリケーションを閉じます。アプリケーションが意図した機能を提供できない状況にある場合、推奨されるアプローチは、問題の性質とユーザーが実行できる可能性のあるアクション (WiFi をオンにする、位置情報サービスを有効にするなど) を示すアラートをユーザーに表示することです。ユーザーが自分の判断でアプリケーションを終了できるようにします。

警告: exit 関数を呼び出さないでください。exit を呼び出すアプリケーションは、正常な終了を実行してホーム画面に戻るのではなく、クラッシュしたように見えます。さらに、exit を呼び出すと -applicationWillTerminate: および同様の UIApplicationDelegate メソッドが呼び出されないため、データが保存されない場合があります。

開発中またはテスト中にアプリケーションを終了する必要がある場合は、abort 関数または assert マクロを使用することをお勧めします。

出典: iOS Developer Library テクニカル Q&A QA1561

于 2013-06-27T05:27:47.107 に答える