질문이 처음이므로 & 게시 코드가 필요하므로 필요한 모든 것을 포함 시켰 으면합니다.그냥 navigationController를 사용하여 UITableView의 데이터를 다시로드하는 방법을 알아낼 수 없습니다.
내 다른 애플 리케이션 중 몇 가지에서 나는 성공적으로 UITableView에서 reloadData 수 있지만 몇 가지 이유로 여기에서 작동하도록 얻을 수 없습니다.
새로운 클래스가로드 될 때까지 navigationController를 사용하고 UITableView에서 몇 개의 레벨을 드릴 다운하는 중입니다. 두 개의 유사한 plist 파일간에 전환하는 두 개의 버튼이 있으므로 tableView가 실제로 다시로드됩니다 (Data. plist & Data2.plist
이것은 결국 개별 작업이 나열되고 사용자 (드라이버)가 입력/출력 버튼으로 시간 초과를 펀치하는 작업 표 종류의 앱이 될 것입니다. 지금은 내가 원하는 것은 다른 plist를로드하고 다시 올라가서 새로운 plist 데이터가로드되었음을 알리는 버튼을 드릴 다운하고 클릭하는 것입니다. 내 문제는 내가 전혀 다시로드 tableView 얻을 수 없다는 것입니다. 나는 다른 곳에서도 [self.tableView reloadData] & [myTableView reloadData] (IB를 통해 연결 한 것)의 다양한 변형을 시도했지만 그 중 아무 것도 작동하지 않습니다. 나는 현재 navigationViewroller가 사용되지 않을 때 detailViewController (버튼이있는 곳)의 rootViewController (tableView가있는 곳)에있는 메소드를 호출하고 있고, 다른 앱에서는 기본 프로세스가 작동합니다. navigationController는이 앱에서 나를 던지고있는 것 같습니다. 쉬운 해결책을 찾을 수 있기를 바랍니다. 내 코드는 지금까지 다음과 같습니다
AppDelegate.m
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
RootViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
//THIS ESTABLISHES WHICH PLIST TO LOAD BASED ON THE BUTTON CLICKED
plistToUse = [[NSUserDefaults standardUserDefaults] objectForKey:@"plistToUse"];
if (plistToUse == @"Data.plist") {
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *DataPath = [Path stringByAppendingPathComponent:@"Data.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:DataPath];
self.data = tempDict;
[tempDict release];
} else if (plistToUse == @"Data2.plist") {
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *DataPath = [Path stringByAppendingPathComponent:@"Data2.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:DataPath];
self.data = tempDict;
[tempDict release];
} else {
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *DataPath = [Path stringByAppendingPathComponent:@"Data.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:DataPath];
self.data = tempDict;
[tempDict release];
}
if(CurrentLevel == 0) {
NSArray *tempArray = [[NSArray alloc] init];
self.tableDataSource = tempArray;
[tempArray release];
self.tableDataSource = [self.data objectForKey:@"Rows"];
self.navigationItem.title = @"Choose Driver";
} else if (CurrentLevel == 1) {
self.navigationItem.title = @"Choose Day";
} else if (CurrentLevel == 2) {
self.navigationItem.title = @"Choose Job";
} else if (CurrentLevel == 3) {
self.navigationItem.title = @"Job Details";
} else {
self.navigationItem.title = CurrentTitle;
}
}
-(void)update {
dvController.labelHelper.text = @"UPDATED"; //USED TO SEE IF A LABEL IN THE BUTTON CLASS WILL UPDATE
NSArray *tempArray = [[NSArray alloc] init];
self.tableDataSource = tempArray;
[tempArray release];
self.tableDataSource = [self.data objectForKey:@"Rows"];
self.navigationController.navigationItem.title = @"Choose Driver";
self.navigationController.title = @"THE TITLE";
[myTableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
unsortedIndex=1;
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.tableDataSource count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
dictionary = [self.tableDataSource objectAtIndex:indexPath.row];
cell.textLabel.text = [dictionary objectForKey:@"Title"];
NSArray *Children = [dictionary objectForKey:@"Children"];
if ([Children count] == 0) {
Titles = [dictionary objectForKey:@"Title"];
in1 = [[NSUserDefaults standardUserDefaults] objectForKey:@"InTime1"];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", in1];
}
in1 = [[NSUserDefaults standardUserDefaults] objectForKey:@"InTime1"];
out1 = [[NSUserDefaults standardUserDefaults] objectForKey:@"OutTime1"];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@:%@", in1, out1];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
dictionary = [self.tableDataSource objectAtIndex:indexPath.row];
NSArray *Children = [dictionary objectForKey:@"Children"];
DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
if([Children count] == 0) {
[self.navigationController pushViewController:dvController animated:YES];
dvController.labelSiteName.text = [dictionary objectForKey:@"Company"];
dvController.labelSiteAddress.text = [dictionary objectForKey:@"Address"];
dvController.labelSiteNotes.text = [dictionary objectForKey:@"Notes"];
[dvController.mapView setMapType:MKMapTypeStandard];
[dvController.mapView setZoomEnabled:YES];
[dvController.mapView setScrollEnabled:YES];
dvController.mapView.showsUserLocation = YES;
[dvController release];
}
else {
RootViewController *rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];
rvController.CurrentLevel += 1;
rvController.CurrentTitle = [dictionary objectForKey:@"Title"];
[self.navigationController pushViewController:rvController animated:YES];
rvController.tableDataSource = Children;
[rvController release];
}
}
DetailViewController.m 이러한 데이터 중 하나와 함께있는 tableView를 다시로드해야하는 두 개의 버튼이 있습니다. plist 또는 Data2.plist
-(IBAction)getInTime1:(id)sender {
plistToUse = @"Data.plist";
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:plistToUse forKey:@"plistToUse"];
[defaults synchronize];
[rvController update];
}
-(IBAction)getOutTime1:(id)sender {
plistToUse = @"Data2.plist";
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:plistToUse forKey:@"plistToUse"];
[defaults synchronize];
[rvController update];
}
감사합니다. 당신이 줄 수있는 도움.
은 UITableView 하위 클래스 인 RootViewController입니까? –
@Monty는 처음으로 테이블이 보이지 않습니다 ..? 그리고'tableView'의'delegate'과'dataSource'가 당신의 파일 소유자에게 링크되어 있는지 확인하십시오. – vishy
기본적으로 Xcode에서 새로운 Master Detail 프로젝트를 만들었을 때와 같은 설정을 사용하고 있습니다 (4.5를 사용하고 있습니다) . – Monty