使用特定子视图重新加载/刷新视图控制器

时间:2014-10-17 15:22:44

标签: ios objective-c iphone uiview uiviewcontroller

我有一个带有几个特定子视图的UIViewController(如PassBook Views)。 当我退出视图时,我想重新加载ViewController及其所有子视图。我调用rootviewController的viewDidLoad和viewWillLayoutSubviews方法,如下所示:

- (IBAction)disconnect:(UIStoryboardSegue *)segue {
    self.sourceVC = segue.sourceViewController;
    self.disconnected = YES;
    ViewController *rootController=(ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
    [rootController viewDidLoad];
    [rootController viewWillLayoutSubviews];}

在我的ViewController类中:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setupPBDataSource];}


- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];

CGRect frame = self.view.bounds;
CGFloat maxY = (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)\
                ? 20 : 0);
frame.origin.y += maxY;
frame.size.height -= maxY;

if (!_passbookView) {
    self.passbookView =
    [[PBPassGroupStackView alloc] initWithFrame:frame datasource:self];
    [self.view addSubview:self.passbookView];
} else {
    [self.passbookView removeFromSuperview];
    self.passbookView =
    [[PBPassGroupStackView alloc] initWithFrame:frame datasource:self];
    [self.view addSubview:_passbookView];
}}

我只是想知道如何重新加载我的新passbookView(在登录segue上创建两个新的子视图)???感谢。

0 个答案:

没有答案