이것이 iphone/ipad의 여러보기간에 데이터 또는 메시지를 전달하는 올바른 방법인지 궁금합니다.dismissModalViewController보기 컨트롤러간에 전달하는 메시지
두 개의 ViewController, FirstViewController 및 SecondViewController가 있습니다. 다음 두 가지 방법으로 설정 한 두 ViewController 모두에서 NSString * 메시지를 속성으로 사용합니다.
FirstViewController.h에서 SecondViewController.h 클래스를 가져옵니다. 사용자가
내 SecondViewController.h에서-(IBAction)ShowSecondView
{
SeondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]];
secondView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
secondView.message = @"Presented from First View";
[self presentModalViewController:secondView animated:YES];
[secondView release];
}
, 내가 클래스를 가져 오는 첫 번째보기의 버튼을 탭하면 내가 호출되는이 IBAction를이 FirstViewController.h 사용자가 버튼을 탭하면 내가 호출되는이 IBAction를이 두 번째보기는
-(IBAction)GoBack
{
FirstViewController *firstView = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:[NSBundle mainBundle]];
firstView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
firstView.message = @"Presented from Second View";
[self presentModalViewController:firstView animated:YES];
[firstView release];
}
메시지는 성공적으로보기 사이를 통과하지만 난에 부모보기로 돌아가려면 현재 뷰 컨트롤러를 해제하기 위해 [self dismissModalViewController]
를 사용하는 경우, 메시지가 전달되지 않습니다.
내 제안이 대리자를 사용 중입니다 – Bonny