Custom size for Modal View loaded with Form Sheet presentation

前端 未结 10 768
予麋鹿
予麋鹿 2021-02-01 12:44

I\'m trying to load a UIViewController in iPad with Form Sheet presentation. The problem is the size of this new view, i put the size values in the IBuilder but the modal view t

10条回答
  •  温柔的废话
    2021-02-01 13:22

    I solved it like @Stuart Campbell and @Viruss mca.

    Edited

    After @Erich's comment, I rewrote it to run in iOS 8 too. Below is the code:

      HelpViewController * viewController = [[[HelpViewController alloc] init]];
      viewController.modalPresentationStyle=UIModalPresentationFormSheet;
      [self presentViewController:viewController animated:YES completion:nil];
    

    --

    //HelpViewController.m
    
    - (void) viewWillLayoutSubviews{
        [super viewWillLayoutSubviews];
        if (!didLayout) {
            [self layout];
            didLayout = YES;
        }
    }
    - (void) layout{
        self.view.superview.backgroundColor = [UIColor clearColor];
        CGRect screen = self.view.superview.bounds;
        CGRect frame = CGRectMake(0, 0, , );
        float x = (screen.size.width - frame.size.width)*.5f;
        float y = (screen.size.height - frame.size.height)*.5f;
        frame = CGRectMake(x, y, frame.size.width, frame.size.height);
    
        self.view.frame = frame;
    }
    

提交回复
热议问题