Ios 如何重新加载父视图
如何在关闭Ios 如何重新加载父视图,ios,cocoa-touch,Ios,Cocoa Touch,如何在关闭UIModalPresentationFormSheet视图后更新父视图。如果我使用普通视图,我可以重新加载父视图。仅在UIModalPresentationFormSheet中发布。请帮帮我。谢谢 navigationController.modalPresentationStyle = UIModalPresentationFormSheet; 如果我使用 navigationController.modalPresentationStyle = UIModalPresen
UIModalPresentationFormSheet
视图后更新父视图。如果我使用普通视图,我可以重新加载父视图。仅在UIModalPresentationFormSheet
中发布。请帮帮我。谢谢
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
如果我使用
navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
我可以刷新父表视图。仅在UIModalPresentationFormSheet中发布,但我需要使用UIModalPresentationFormSheet进行弹出视图。请帮帮我。谢谢我最简单的方法:
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
//FormController.h
@protocol FormDelegate;
@interface FormController : UIViewController
...
@property (nonatomic, assign) id <FormDelegate> delegate;
...
@end
@protocol FormDelegate
-(void)didDismissForm;
@end
//MainViewController.h
#import "FormController.h"
@interface MainViewController : UIViewController <FormDelegate>
...
您应该委托PresentModalView的parentView,并且应该在PresentModalView的ViewWillEnglishe上调用referesh方法 否则,您可以尝试推送通知并在parentView中观察它
- (void) refreshMyParentViewController{
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center postNotificationName:@"RefreshNeeded" object:self userInfo:refreshData];
}
//在ParentViewController中——添加观察者以检测数据。
//以及要调用的方法
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(delegateMethod:)
name:@"RefreshNeeded" object:nil];
- (void)delegateMethod:(NSNotification *)notification {
NSLog(@"%@", notification.userInfo);
NSLog(@"%@", [notification.userInfo objectForKey:@"RefreshObject"]);
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(delegateMethod:)
name:@"RefreshNeeded" object:nil];
- (void)delegateMethod:(NSNotification *)notification {
NSLog(@"%@", notification.userInfo);
NSLog(@"%@", [notification.userInfo objectForKey:@"RefreshObject"]);
}
为什么要重新加载父视图?我在“UIModalPresentationFormSheet”视图中编辑了一些数据。我想在父视图中显示更改。您需要其他人来通知更改(KVO、NSNotificationCenter、委托、传递引用和调用方法,多种方式)@Joshy Joseph。。。。他(@xlc0212)告诉我们的方法确实有很多……我认为最简单的方法是在“viewwillbeen”中重新加载。关闭表单后,导航控制器中的上一个控制器将调用“ViewWillApprove”。如果使用navigationController.modalPresentationStyle=UIModalPresentationFullScreen;我可以刷新父表视图。仅在UIModalPresentationFormSheet中发布,但我需要使用UIModalPresentationFormSheet进行弹出视图。请帮帮我。感恩节也是这样。