arc 프로젝트에 tableView가 있습니다. 내가 초 동안 심지어 그것을 스크롤하면 모든 데이터가 숨겨 지거나 사라집니다.UITableViewCell 스크롤 후 데이터가 사라집니다.
Strong 속성을 통해 다른 컨트롤러의 데이터를 전달하고 있습니다. 여기
CTableViewController* cTableVc=[[CTableViewController alloc] initWithNibName:@"CTableViewController" bundle:nil];
cTableVc.cArray=[[NSArray alloc] initWithArray:[MyVC pathForAllCardsInDocumentDiretory]];
cTableVc.view.frame=CGRectMake(0, 0, cTableVc.view.frame.size.width, cTableVc.view.frame.size.height);
[self.view addSubview:cTableVc.view];
은 내 재산 문제는 당신이보기 컨트롤러를 생성하고 새로운 뷰 컨트롤러의 뷰를 추가 코드입니다
@property(strong, nonatomic) NSArray* cArray;
CTableViewController.m있는 tableView 방법
- (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 [_cardArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = @"CTableViewCell";
CTableViewCell *cell = (CTableViewCell *) [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CTableViewCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CTableViewCell *) currentObject;
break;
}
}
}
// Configure the cell...
NSString* strPath=[cArray objectAtIndex:indexPath.row];
cell.cardImageView.image=[UIImage imageWithContentsOfFile:strPath];
cell.cardNameLbl.text=[NSString stringWithFormat:@"My Card %d", arc4random() % 9];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
return cell;
}
'cellForRowAtIndex :'는'cArray'에서 데이터를 사용하지 않습니다. 왜 안돼? – rmaddy
실제로는 단순성을 위해 해당 행을 제거했습니다. 그것을 명확하게 편집. – NaXir
코드의 첫 번째 세그먼트에서'[self.view cTableVc.view];는 무엇입니까? – sha