1
我有一个UITableView
显示一个自定义UITableViewCell
嵌入在另一个UITableView
。UiTableView内部自定义UITableViewCell
类定制UITableViewCell
的是:
@interface XYZcustomtakeawayTableViewCell: UITableViewCell <UITableViewDataSource,UITableViewDelegate>
{
NSString * order;
}
@property (strong, nonatomic) IBOutlet UITableView * tableviewinside;
@property (nonatomic, retain) NSString * order;
@end
#import "XYZcustomtakeawayTableViewCell.h"
@implementation {XYZcustomtakeawayTableViewCell
{
NSMutableArray * dataArray;
}
@synthesize tableviewinside, order;
- (id) initWithStyle: (UITableViewCellStyle) style reuseIdentifier: (NSString *) reuseIdentifier: (NSString *) Order
{
self = [super initWithStyle: style reuseIdentifier: reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void) awakeFromNib
{
// Initialization code
dataArray = [[order componentsSeparatedByString: @ ""] mutableCopy];
self.tableviewinside.delegate = self;
self.tableviewinside.dataSource = self;
}
- (void) setSelected: (BOOL) selected animated: (BOOL) animated
{
[super setSelected: selected animated: animated];
// Configure the view for the selected were
}
- (NSInteger) numberOfSectionsInTableView: (UITableView *) tableView
{
return 1;
}
- (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) section
{
dataArray = [[order componentsSeparatedByString: @ ""] mutableCopy];
dataArray.count return;
}
- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath
{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: @ "cell"];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: @ "cell"];
}
cell.textLabel.text = [dataArray objectAtIndex: indexPath.row];
return cell;
}
@end
类的UITableViewController
import <UIKit/UIKit.h>
@interface XYZGestisciTakeAwayTableViewController: UITableViewController
@end
的NSString * ordine_1 = @ “1个玛格丽塔,2塔那”;
- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath
{
static NSString * simpleTableIdentifier = @ "cell";
XYZcustomtakeawayTableViewCell * cell = (XYZcustomtakeawayTableViewCell *) [tableView dequeueReusableCellWithIdentifier: simpleTableIdentifier];
if (cell == nil)
{
NSArray * nib = [[NSBundle mainBundle] loadNibNamed: @ "custom_prenotazioni" owner: self options: nil];
cell = [nib objectAtIndex:0];
}
cell.ordine = ordine_1; //FAILURE !!!!!!!!!!!!
return cell;
}
运行应用程序会停止,为什么? 它工作,如果我删除cell.ordine = ordine_1;
。
你在你的自定义单元上声明'ordine'在哪里?我只能看到'order'和'tableviewinside'的属性。 – Stonz2
它崩溃还是停止?还有@ Stonz2说的 – random