我有一個UITableViewCell具有不知道我是否應該把邏輯中的UITableViewController或在UITableViewCell中
- 兩個標籤
- 一個TextView的
- 一號「接受」按鈕
- 一個「刪除「按鈕
接受和刪除按鈕基本上都是刪除單元格。接受更改一些數據的狀態,它會顯示在另一個屏幕上,刪除將完全刪除它。
這裏是我的方法來顯示一個tableviewcell
- (InvitationCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString* cellIdentifier = @"Identifier";
InvitationCell *cell = (InvitationCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
// Create a new PFObject Object
PFObject *connection = nil;
connection = [self.tableData objectAtIndex:[indexPath row]];
PFObject *inviterCodeName = connection[@"Inviter"];
[inviterCodeName fetch];
cell.inviterCodeName = inviterCodeName; // Allows us to use this in the cell
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
[dateFormatter setLocale:enUSPOSIXLocale];
[dateFormatter setDateFormat:@"EEE, MMM, h:mm a"];
cell.dateLabel.text = [dateFormatter stringFromDate:[connection updatedAt]];
cell.codeName.text = [NSString stringWithFormat:@"Invitee Code Name: %@", inviterCodeName[@"codeName"]];
if (inviterCodeName[@"description"] == nil) {
cell.codeNameDescription.text = @"";
} else {
cell.codeNameDescription.text = [NSString stringWithFormat:@"%@", inviterCodeName[@"description"]];
}
return cell;
}
什麼我不能確定的是我是否把接受/拒絕在實際的UITableViewCell類的方法,或者如果我把它們具有所有類的UITableView方法?
如果我將它們放在具有所有UITableView方法的類中,如何使用自定義單元格中的兩個按鈕?我是否爲他們製作網點?是否有另一個我需要使用的委託方法?
tableviewcell是一種視圖,它應該只關心用戶正在查看的內容 – amar
代表團是最好的方式。在這裏,MVC最適合使用。 – santhu