-2

我正在使用 card io API 来扫描信用卡,然后将该信息用于表格视图。我必须填写以下字段:

-信用卡号 -cvv -到期日期(我附加了字符串,因为它们用作单独的变量)

这是我的代码:

.m 文件

- (void)userDidProvideCreditCardInfo:(CardIOCreditCardInfo *)info inPaymentViewController:(CardIOPaymentViewController *)scanViewController {

        BillingTableViewCell *aCell;

        NSString *myString = info.expiryMonth;
        NSString *otherString = [myString stringByAppendingString: info.expiryYear];

        aCell = (BillingTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
        aCell.text.text = info.cardType;


        aCell = (BillingTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];
        aCell.textLabel.text = info.cardNumber;


        aCell = (BillingTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
        aCell.text.text = info.cvv;


        aCell = (BillingTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:3 inSection:0]];
        aCell.text.text = info.zip;


        aCell = (BillingTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:5 inSection:0]];
        aCell.text.text = otherString;


    [scanViewController dismissModalViewControllerAnimated:YES];

这是我的 .h 文件:

property(nonatomic, assign, readwrite) NSUInteger expiryMonth;  
@property(nonatomic, assign, readwrite) NSUInteger expiryYear;  
@property(nonatomic, copy, readwrite) NSString *cvv;
@property(nonatomic, copy, readwrite) NSString *zip;

我不断提出线程错误,并且信息没有放入文本字​​段。我究竟做错了什么?

错误:

0x38fa65c6:  push.w {r3, r4}
0x38fa65ca:  ldr    r4, [r0] thread 1: EXC_BAD_ACCESS (code=1, address=0x5)
0x38fa65cc:  lsr.w  r9, r1, #2
4

1 回答 1

2

如果您尝试填充 UITableView 您应该实现以下两种方法:

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

- (NSInteger)tableView:(UITableView *)tableView 
 numberOfRowsInSection:(NSInteger)section

然后在第一个方法 ( tableView: cellForIndexPath:) 中,您将创建一个UITableViewCell并用您的数据填充它的属性。

确保将 ViewController 设置为 UITableView 的委托和数据源。

于 2013-07-19T08:35:49.110 回答