Tôi có một UINavigationController đơn giản mà đẩy UIViewController vào ngăn xếp thông qua một segue tùy chỉnh. Tôi sau đó thực hiện một IBAction trên UIViewController đầu tiên để thực hiện một hành động thư giãn và tôi thực hiện segueForUnwindingToViewController. Thật không may, segueForUnwindingToViewController không được gọi (tôi đã xác nhận rằng canPerformUnwindSegue đang được gọi trên VC đầu tiên).Unwind Segue cho UINavigationController
Tôi chưa thấy bất kỳ ví dụ đơn giản nào về hành vi này. Có ai giúp đuợc không? Cảm ơn.
Đây là mã từ trình điều khiển chế độ xem gốc của NavigationController.
- (IBAction) unwindFromSegue:(UIStoryboardSegue *)segue {
// unwinds back to here
//[self performSegueWithIdentifier:@"UnwindToObjectManageSegue" sender:self];
}
- (BOOL)canPerformUnwindSegueAction:(SEL)action fromViewController:(UIViewController *)fromViewController
withSender:(id)sender {
return YES;
}
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
return YES;
}
- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController
fromViewController:(UIViewController *)fromViewController
identifier:(NSString *)identifier {
ObjectManageObjectDetailSegue *segue = [[ObjectManageObjectDetailSegue alloc] initWithIdentifier:identifier source:fromViewController destination:toViewController];
[segue setUnwinding:YES];
return segue;
}
Tôi cho rằng bạn đã làm theo các bước từ [câu trả lời này] (http://stackoverflow.com/a/12843906/335858) nhưng mọi thứ không hiệu quả với bạn, đúng không? – dasblinkenlight
Đúng vậy. Tôi theo sau đó đến một T. Thật không may, segue thư giãn của tôi không được gọi. Mã định danh đang được gửi chính xác, nhưng bản thân nó không bao giờ được gọi. – Clay
Nó sẽ là tuyệt vời nếu ai đó có thể có thể gửi một dự án mẫu mà minh họa những gì đã được đăng trong chủ đề đó. Tôi nghĩ đó là một ví dụ tuyệt vời, nhưng nó khá phổ biến. – Clay