TableView에서 Ringtones 디렉터리의 내용을 나열하려고하지만 셀당 파일 대신 모든 셀의 디렉터리에서 마지막 파일 만 가져옵니다. 그것은 잘로드목록에있는 UITableView 목록 내용
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
Profile_ManagerAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
cell.hidesAccessoryWhenEditing = YES;
}
cell.accessoryType = UITableViewCellAccessoryNone;
//cell.textLabel.text = @"No Ringtones";
//cell.textLabel.text = @"Test";
NSString *theFiles;
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *fileList = [manager directoryContentsAtPath:@"/Test"];
for (NSString *s in fileList){
theFiles = s;
}
cell.textLabel.text = theFiles;
return cell;
}
내가 NSLog
를 사용하는 경우, 오류가,이 디렉토리에있는 모든 파일을 잘 나열하지 : 이것은 내 코드입니다. 심지어 [s objectAtIndex:indexPath.row]
시도했지만 objectAtIndex : 오류가 발생합니다. 누구든지 아이디어가 있습니까?
주 파일의 아무 곳에서나 파일에 액세스 할 수 있도록 머리글에 배열을 만들어야합니다. 그렇게하지 않으면 숫자를 사전 설정하지 않는 한 어떻게 테이블 항목 수를 설정할 수 있습니까? 그러나 사람들이 파일을 추가하거나 삭제하면 디렉토리의 항목 수를 얻는 것이 더 쉬워집니다. – Maximilian