요점은 사용자 정의 셀이 있고 그 안에 2 개의 레이블과 1 개의 텍스트 필드가 있습니다. 라벨과 텍스트 필드 모두 사용자로부터 입력을받습니다. 나는 또한 그 안에 uitableview가 다른보기가 있습니다. 내 질문에 어떻게 내가 uitableview에 세포를 채울 수 있습니까? 도와주세요.셀을 사용하여 tableview를 채우려면 어떻게해야합니까?
내 tableviewcontroller 내 코드입니다.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1; // i want to populate this using 'count' but i dont know how.
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:[CustomCell reuseIdentifier]];
if (cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
cell = _customCell;
_customCell = nil;
}
cell.titleLabel.text = [NSString stringWithFormat:@"%@",titleTextString];
cell.timerLabel.text = [NSString stringWithFormat:@"%@",timerString];
cell.statusLabel.text = [NSString stringWithFormat:@"%@",statusString];
return cell;
}
사용자가 입력을 완료 한 후 추가 버튼을 누르면 어떻게하면 내 tableview가 채워 집니까? 제발 코드에 도움이되지 않으면 제발. 나는 초보자이고 나는 이해하기가 어렵다.
답장을 보내 주셔서 감사합니다. 그러나 numberOfRowsInSection 안에 무엇을 써야합니까? 내 말은, 어떻게하면 "추가"버튼을 누르면 tableview에서 내 세포를 채울 수 있습니다. – SyntaxError
일반적으로 새 데이터를 모두 푸시 할 NSMutableArray가 있으므로 추가 버튼을 클릭 할 때마다 해당 배열에 새 데이터가 추가됩니다. 그러므로 배열의 크기를 보통'numberOfRowsInSection'에서 사용할 수 있습니다.이 경우'[yourArray count];'또한 행 데이터가 혼합 된 것이면'NSMutableDictionary'를 대신 사용할 수 있습니다. – antf
음 ...죄송합니다, cellForRowAtIndexPath 안에 무엇을 써야합니까? 내가 배열을 반환 numberOfRowsInSection 내 배열을 넣어 [배열 개수]; 하지만 그 cellForRowAtIndexPath 내부에 무엇을 추가해야합니까? 고맙습니다. – SyntaxError