gpt4 book ai didi

objective-c - 如何在单击按钮时在同一窗口中加载新 View ?

转载 作者:行者123 更新时间:2023-12-02 05:30:20 24 4
gpt4 key购买 nike

我有一个带按钮的 View Controller 。我希望在按下按钮时通过我的 View-Controller 加载新 View 。它不会替换现有 View ,我希望它小于屏幕并在我点击小 View 时隐藏。

应该如何在代码中实现?

最佳答案

- (IBAction)button:(id)sender 
{
UIView *view2=[[UIView alloc]initWithFrame:CGRectMake(0,0,200,200)];
[self.view addSubview:view2];
UITapGestureRecognizer *Tap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(Tapview)] autorelease];
[view2 addGestureRecognizer:Tap];
}

-(void)Tapview
{
[view2 removeFromSuperview];
}

关于objective-c - 如何在单击按钮时在同一窗口中加载新 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12489425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com