iphone - 我可以动态更改 UIView 的内容吗?

标签 iphone objective-c ios cocoa

我想在不使用removeFromSuperView和addSubview的情况下动态更改UIView的内容。代码是我想要做的事情的图像。

int screenWidth = [[UIScreen mainScreen] bounds].size.width;
int screenHeight = [[UIScreen mainScreen]bounds].size.height;
UIView *currentView = [[UIView alloc]initWithFrame:CGRectMake(0,0,screenWidth,screenHeight)];
UIView *nextView = [[UIView alloc]initWithFrame:CGRectMake(0,0,screenWidth,screenHeight)];

[self.view addSubview:currentView];

currentView = nextView;

//when this code run,appearing currentView swap nextView.
[self.view reload];

最佳答案

当然。如果您希望它看起来不错,请使用您想要的属性创建“结束” View 并使用静态 transition方法:+transitionFromView:toView:duration:options:completion: .

这将根据需要删除和添加 View ,这样您就不必调用这些方法。否则,您可以使用-setHidden: janusfidel 建议的方法,以隐藏您不想看到的 View 。

关于iphone - 我可以动态更改 UIView 的内容吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13154729/

相关文章:

objective-c - NSDirectoryFileType 已弃用。替代品是什么?

ios - 如何存储 NSDateComponents 的时间部分?

ios - 如何在快速单击弹出窗口 ViewController 上的按钮时导航到 TabBar ViewController?

ios - 设置状态栏颜色以匹配 UISearchBar

iphone - iPhone 上的 Git 客户端,可能吗?如何?

ios - 如何在 ViewController 及其 NavigationController 上添加 UIview

android - https .mp3 链接适用于不在 2.3 及以下版本的平板电脑(11+ api)

iphone - 如何使用 Mobile Safari 中的链接使用 Twitter 应用程序打开用户的 Twitter 个人资料?

ios - 修复 : . 中的错误重复符号 _response ...:链接器命令失败,退出代码为 1(使用 -v 查看调用)

iphone - NSDate对象显示错误的时间