Documents Directory의 데이터를 표시하는 UITableView를 설정하려고합니다.Documents Directory의 파일을 UITableView-iOS5에 표시하십시오.
이 나는 스토리 보드없이 내 응용 프로그램을 만드는 오전
나는 등 구글과 포럼에서 많은 예를 시도로 모든 코드 그래서 조금, 코드에 대한 손실입니다.
위젯 및 DataView가 표시되도록 UITableView가 표시되어 있습니다. 콘텐츠가 필요합니다.
나는 당신을 표시하려면이 코드를 가지고 있지만, 그것은 어떤 데이터가 표시되지 않습니다
- (void)viewDidLoad
{
[super viewDidLoad];
_firstViewWithOutNavBar = [[UIView alloc] init];
_firstViewWithOutNavBar.frame = CGRectMake(self.view.frame.origin.x, 0, self.v iew.frame.size.width, self.view.frame.size.height);
_firstViewWithOutNavBar.backgroundColor = [UIColor whiteColor];
[self.view addSubview:_firstViewWithOutNavBar];
UITableView *tableView = [[UITableView alloc] init];
tableView.frame = CGRectMake(self.view.frame.origin.x, 0, self.view.frame.size.width, self.view.frame.size.height);
tableView.delegate = self;
tableView.dataSource = self;
[_firstViewWithOutNavBar addSubview:tableView];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//alloc and init view with custom init method that accepts NSString* argument
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:indexPath.row];
NSString*pathToPass = [documentsDirectory stringByAppendingPathComponent:
[tableView cellForRowAtIndexPath:indexPath].textLabel.text]; //pass this.
NSLog(@"%@", pathToPass);
//_nsarray = [[NSArray alloc] initWithContentsOfFile:pathToPass];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_nsarray count];
NSLog(@"%@", _nsarray);
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [NSString stringWithFormat:@"%@",[_nsarray objectAtIndex:indexPath.row]];
return cell;
}
어떤 도움이 좋을 것.
슈퍼 - 코드가 작동하여 매우 멋지게 만들었습니다 :-) –