Я пытаюсь создать 3 ячейки табличного представления, используя код (без пера).У меня возникли проблемы с получением кода для работы.Я предполагаю, что не понимаю подход правильно.Кто-нибудь может посоветовать мне, как правильно идти вперед?Любая помощь по этому вопросу будет принята с благодарностью!
Спасибо!
Zhen Hoe
Мой фрагмент кода выглядит следующим образом:
- (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 3;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
int row = [indexPath row];
UITableViewCell *startCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
UITableViewCell *durationCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
UITableViewCell *radiusCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
startCell.textLabel.text = @"Start:";
durationCell.textLabel.text = @"Duration:";
radiusCell.textLabel.text = @"radius";
if (row == 0)
{
return startCell;
}
else if (row == 1)
{
return durationCell;
}
return radiusCell;
}
РЕДАКТИРОВАТЬ (19 /05/11)
После просмотра ваших ответов я все еще не могу отобразить ни одной ячейки в своем табличном представлении.Это связано с тем, как я инициализировал свою таблицу?
//Initialization
UITableView *tv = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.settingsView.frame.size.height)
style:UITableViewStyleGrouped];
self.tableView = tv;
[self.view addSubview:tableView];
После чего у меня появляется анимация для расширения tableView
[UIView animateWithDuration:0.3 animations:^{
[self.tableView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-self.picker.frame.size.height)];
}];
Ребята, видите ли вы какие-либо проблемы с вышеупомянутым?Что-нибудь, что вызывает мой показ ячеек, терпит неудачу?
Спасибо!
Жен