Под «статическими данными» вы подразумеваете жесткое кодирование, а не источник данных?
В любом случае процесс одинаков. Вы должны вернуть ячейки через cellAtIndexPath: Вы можете сделать это довольно просто с помощью блока «if», предполагая, что все, что вам нужно, это пара жестко закодированных строк.
Например:
// How many sections in the table? Hard coded to 1 here
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// How many rows in the table? Hard coded to 2 here
- (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection:(NSInteger)section {
return 2;
}
// Method for returning data from anywhere, even hard coded
// Notice how we use row and section, these tell us which cell in the table we are returning
- (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
NSInteger row = [indexPath row];
NSInteger section = [indexPath section];
// Dequeue a cell using a common ID string of your choosing
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myCellID"];
// Return cells with data/labels/pretty colors here
if (row == 0)
{
cell.textLabel.text = @"I can haz cheezburger";
}
else if (row == 1)
{
cell.textLabel.text = @"I hate lol catz";
}
// Pretty em up here if you like
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
return cell;
}
Это довольно просто, когда вы знаете способ Какао, но это не "просто".