Xcode: How To Create A PopUp View Controller That Appears In Another View Controller

后端 未结 7 571
-上瘾入骨i
-上瘾入骨i 2021-01-31 12:27

Basically what I am trying to figure out to do is, say I have one View Controller, called V1, that has a regular view inside it and a button. Now, when you tap that button, I wa

7条回答
  •  执笔经年
    2021-01-31 12:58

    You can create such view by setting appropriate property type of modalPresentationStyle. See my example below:

    UIViewController *V2 = [[UIViewController alloc] init];
    V2.modalPresentationStyle = UIModalPresentationFormSheet;
    V2.modalTransitionStyle = UIModalTransitionStyleCoverVertical;     
    [V1 presentViewController:V2 animated:YES completion:nil];
    V2.view.superview.frame = CGRectMake(0, 0, 540, 620); //it's important to do this after presentModalViewController
    V2.view.superview.center = V1.view.center;
    [V1 release];
    

提交回复
热议问题