이 항목을 클릭하고 상세한보기로 이동 컨트롤러 (가) 방법 스와핑 차이
하다니 사용 무엇에 보인다 "pushViewController"의 표준 UINavigationController 개념으로, "추가"새 레코드 단추를 클릭하면 "presentModalViewController"을 통해 레코드를 추가하는 새로운보기가 시작됩니다. 즉, 두 가지 경우 모두 pushViewController 방식을 사용하여 접근 방식을 동일하게 할 수 없었습니까?
실제로 각 방법을 사용한 위치에 이점이 있습니까? 나는 꽤 볼 수 없다. 나는 애플이 다른 시나리오를 위해이 다른 접근법을 선택해야 할 무언가가 있었음에 틀림 없다. 예를 들어
사용자에게 어떠한 차이 (즉 UI 차이 또는 기능적 차이 )들이 알 것이다?
어떤 개발자 에 대한 차이 (또는 장점/단점) 예를 들어
, 당신과 pushViewController 방식 대신에 "추가"시나리오에 대한 presentModalViewController 접근 방식을 사용하는 것을 고려한다면 .. .
(b) 데이터를 공유하는 방법의 차이
공통 데이터 객체를 공유하는 방법에 대한 접근 방식이 다른 것처럼 보입니다 - 그래서 접근 방식이 서로 다른 이유가 궁금합니다.
코드 편의에 대한
추출 - (즉, 메인 컨트롤러가 일시적으로 다른보기로 떨어져 통과하고 그들 사이에 공유 된 데이터가되어 두 경우 모두 아이 뷰는 부모에게 다시 전달하는 데 필요한 즉) "편집"을위한:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Create and push a detail view controller.
DetailViewController *detailViewController = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
Book *selectedBook = (Book *)[[self fetchedResultsController] objectAtIndexPath:indexPath];
// Pass the selected book to the new view controller.
detailViewController.book = selectedBook;
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
그러나 대한이
- (IBAction)addBook {
AddViewController *addViewController = [[AddViewController alloc] initWithStyle:UITableViewStyleGrouped];
addViewController.delegate = self;
// Create a new managed object context for the new book -- set its persistent store coordinator to the same as that from the fetched results controller's context.
NSManagedObjectContext *addingContext = [[NSManagedObjectContext alloc] init];
self.addingManagedObjectContext = addingContext;
[addingContext release];
[addingManagedObjectContext setPersistentStoreCoordinator:[[fetchedResultsController managedObjectContext] persistentStoreCoordinator]];
addViewController.book = (Book *)[NSEntityDescription insertNewObjectForEntityForName:@"Book" inManagedObjectContext:addingContext];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addViewController];
[self.navigationController presentModalViewController:navController animated:YES];
[addViewController release];
[navController release];
}
"추가"감사합니다.