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

后端 未结 7 564
-上瘾入骨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:47

    Create UIView for v2 and add in v1.

    - (void)viewDidLoad
    {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [button addTarget:self 
                       action:@selector(aMethod:)
             forControlEvents:UIControlEventTouchDown];
        [button setTitle:@"Show View" forState:UIControlStateNormal];
            button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
        [self.view addSubview:button];
    }
    
    - (void)aMethod:(id)sender 
    {
        CGRect * imageFrame = CGRectMake(10, 90, 300, 300);
        V2 *v2 = [[V2 alloc] initWithFrame:imageFrame];
        [self.view addSubview:v2];
    }
    

提交回复
热议问题