Я довольно новичок в этом Native App dev - я создал приложение, которое содержит UITableViewController для отображения сообщений - все работает нормально, но для стилизации мне нужно изменить это от TableViewController до таблицы, встроенной в viewcontroller.Xcode/ObjectiveC - конвертировать UITableViewController в TableView, встроенный в UIViewController
Я сделал контроллер представления, содержащий представление таблицы и соответствующие связанные пользовательские ячейки/поля и изменил соответствующий файл заголовок, чтобы -
@interface NotificationsListTVController : UIViewController
, но мои методы табличных уже не огнь, и я не уверены, как для их создания?
(код ниже) #pragma метка - Таблица источника данных
- (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.GPTNotifications.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
static NSString *CellIdentifierRead = @"CellRead";
UITableViewCell *cell;
notifications *n = [self.GPTNotifications objectAtIndex:indexPath.row];
if (n.read == false) {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
CustomCellRead *cellReadB = (CustomCellRead *)cell;
cellReadB.notifTitle.text = n.notifTitleD;
cellReadB.notifDate.text = n.notifDateD;
cellReadB.notifMsg.text = n.notifMessage;
return cellReadB;
}
else {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierRead forIndexPath:indexPath];
CustomCell *cellReadB = (CustomCell *)cell;
cellReadB.notifTitle.text = n.notifTitleD;
cellReadB.notifDate.text = n.notifDateD;
cellReadB.notifMsg.text = n.notifMessage;
return cellReadB;
}
}
Убедитесь, что вы установили 'delegate and datasource' tableview. –
См. Дубликат: http://stackoverflow.com/questions/9375903/how-to-interact-with-uitableview-in-uiviewcontroller – petert