我有一個TableView控制器,我想用數組中的對象填充。我正在使用StoryBoard。另外,我不確定是否需要將標籤作爲佔位符類型放置在故事板的單元原型中?如何用對象數組填充TableView?
My aList Mutable Array包含類型爲Homework的對象。 在表的每一行,我要顯示(這些變量已經在我的作業模式設置):
-ClassName
-AssignmentTitle
-DueDate
這裏是我的目前有
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;
}
[從陣列填充一個UITableView]的可能重複(http://stackoverflow.com/questions/4367393/populating-a-uitableview-from-arrays) –