【发布时间】:2013-10-31 23:43:27
【问题描述】:
我有一个 TableView 控制器,我想用数组中的对象填充它。我正在使用故事板。另外,我不确定是否需要在情节提要的 Cell Prototype 中放置 Labels 作为占位符类型?
我的 aList 可变数组包含 Homework 类型的对象。 在表格的每一行中,我想显示(这些是我的作业模型中已经设置的变量):
-类名
-作业标题
-截止日期
这是我目前拥有的
TableViewController.h
@interface AssignmentTableController : UITableViewController
<
AssignmentDelegate
>
@property(strong,nonatomic) Assignment *vc;
@property (strong, nonatomic) NSMutableArray *alist;//array was filled with delegation
@end
TableViewController.m
#pragma mark - Table view data source
- (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.alist count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Homework *ai = [self.alist objectAtIndex:indexPath.row];
//*******I am not sure what to do from Here******
//*******I need to start displaying 1 object per row,displaying what was stated above***
// Configure the cell...
return cell;
}
【问题讨论】:
标签: ios objective-c arrays uitableview