목록보기가 첫 번째보기에 의존하는 다른 tableview로 이어지는 tableview가 있어야합니다. 데이터베이스를 올바르게 설정하고 내 문제는 첫 번째 페이지에서 하나의 항목을 선택하고 처음 두 번째보기로 이동하면 첫 페이지로 돌아가서 두 번째보기로 다시 돌아갈 때 작동합니다. 목록에는 여전히 새로운 값으로로드 된 이전 값이 있습니다. 두 번째보기가로드 될 때마다 배열을 삭제하고 다시 만들 수있는 방법이 있습니까? 내가 어디에서 할 수 있니? 여기 멀티 뷰 아이폰 앱에서 배열을 재설정하는 방법
내 배열은 위임에 초기화된다 : 여기- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self copyDatabaseIfNeeded];
organArray = [[NSMutableArray alloc] init];
procedureArray = [[NSMutableArray alloc] init];
[Organ getInitialDataToDisplay:[self getDBPath]];
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
}
데이터가 내 사용자 정의 클래스의 배열에 추가되는 경우 : 마지막으로
+ (void) getDatabase:(NSString *)dbPath WithOrganID:(NSNumber *)organID
{
RadiologyAppAppDelegate *appDelegate = (RadiologyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
if(sqlite3_open([dbPath UTF8String],&database) == SQLITE_OK){
const char *sql = "select * from Organ";
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK){
while (sqlite3_step(selectstmt) == SQLITE_ROW) {
NSInteger primaryKey = sqlite3_column_int(selectstmt, 0);
Procedure *procedureObj = [[Procedure alloc] initWithPrimaryKey:primaryKey];
procedureObj.procedureName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,1)];
procedureObj.procedureID = sqlite3_column_int(selectstmt,0);
[appDelegate.procedureArray addObject: procedureObj];
[procedureObj release];
}
}
}
else
sqlite3_close(database);
}
, 여기에 내 생각이다 컨트롤러 :
- (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] autorelease];
}
Procedure *procedureObj = [appDelegate.procedureArray objectAtIndex:indexPath.row];
PVCprocedureObj = appDelegate.procedureArray;
cell.textLabel.text = procedureObj.procedureName;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
감사합니다.
내가 내 루트에 didSelectRowAtIndexPath의 배열을 채우는 방법을 호출하고 도움이있는 tableView를 - : 셀을 클릭하면 내부 객체를 전달합니다 뷰 컨트롤러. 너가 말하는게 이거니? –
배열을 다시 초기화하는 배열 모집단 메서드가 호출되기 직전에 호출 한 대리자에서 메서드를 만들었으므로 이제는 훌륭하게 작동합니다. 도와 주셔서 감사합니다! –