Ios 为什么不是';是否将我的数据加载到此UITableView中

Ios 为什么不是';是否将我的数据加载到此UITableView中,ios,objective-c,uitableview,delegates,Ios,Objective C,Uitableview,Delegates,我正在尝试使用UITableView创建行的可编辑部分 由于某种原因,我的数据没有加载到单元格中,并且仍然为零。我一直不明白为什么,有人能给我一些帮助吗 @interface exampleOrderCell : PSTableCell <UITableViewDataSource, UITableViewDelegate> @property (nonatomic, strong) NSMutableArray *tableData; @end @implementation

我正在尝试使用UITableView创建行的可编辑部分

由于某种原因,我的数据没有加载到单元格中,并且仍然为零。我一直不明白为什么,有人能给我一些帮助吗

@interface exampleOrderCell : PSTableCell  <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) NSMutableArray *tableData;
@end

@implementation exampleOrderCell
//- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier specifier:(PSSpecifier *)specifier
- (instancetype)initWithStyle:(UITableViewStyle)style
{

    return self;
}
- (void)viewDidLoad {
    [self viewDidLoad];
    self.tableData = [@[@"One",@"Two",@"Three",@"Four",@"Five"] mutableCopy];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [self.tableData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"ThisCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    // Configure the cell...
    cell.textLabel.text = self.tableData[indexPath.row];

    return cell;
}

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
    NSString *stringToMove = self.tableData[sourceIndexPath.row];
    [self.tableData removeObjectAtIndex:sourceIndexPath.row];
    [self.tableData insertObject:stringToMove atIndex:destinationIndexPath.row];
}

- (IBAction)startEditing:(id)sender {
    self.editing = YES;
}
@end
@接口示例OrderCell:PSTableCell
@属性(非原子,强)NSMutableArray*tableData;
@结束
@实现示例OrderCell
//-(instancetype)initWithStyle:(UITableViewCellStyle)样式重用标识符:(NSString*)重用标识符说明符:(PSSpecifier*)说明符
-(instancetype)initWithStyle:(UITableViewStyle)样式
{
回归自我;
}
-(无效)viewDidLoad{
[自视下载];
self.tableData=[@[@“一”、“二”、“三”、“四”、“五”]可变表副本];
}
-(NSInteger)表格视图中的节数:(UITableView*)表格视图
{
//返回节数。
返回1;
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
//返回节中的行数。
返回[self.tableData count];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“ThisCell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//配置单元格。。。
cell.textlab.text=self.tableData[indexPath.row];
返回单元;
}
-(BOOL)tableView:(UITableView*)tableView可以移动rowatinexpath:(nsindepath*)indepath
{
返回YES;
}
-(void)tableView:(UITableView*)tableView MoveRowatineXpath:(NSIndexPath*)sourceIndexPath到IndeXpath:(NSIndexPath*)destinationIndexPath
{
NSString*stringToMove=self.tableData[sourceIndexPath.row];
[self.tableData removeObjectAtIndex:sourceIndexPath.row];
[self.tableData insertObject:stringToMove atIndex:destinationIndepath.row];
}
-(iAction)开始编辑:(id)发件人{
自编辑=是;
}
@结束

为什么要将表单元格设置为表视图委托和数据源?为什么这个表单元格类有视图控制器方法?@rmaddy我想我需要它们,你建议我删除这个部分吗?这是我几天前发现的一个链接,我试着让它工作起来,但可能我使用了错误的部分,尤其是视图控制器类是表视图的委托和数据源。表单元格作为表的委托或数据源是没有意义的。我建议您阅读
cellforrowatinexpath
中的.您使用的是
dequeueReusableCellWithIdentifier
,如果可重用单元队列中不存在此类对象,则可能为您提供零单元。因此,您必须检查单元格是否为零,然后分配新单元格如果使用“exampleOrderCell”,请检查您的单元格名称,以便在标识符中必须传递静态NSString*CellIdentifier=@“exampleOrderCell”;