iphone - sendSubviewToBack 和 insertSubview :belowSubview: don't work as they should 的问题

标签 iphone objective-c ios cocoa-touch

sendSubviewToBackinsertSubview:belowSubview: 方法有问题。简单地说,我有一个按钮,我将其插入到另一个 View _centerView 下方。我希望按钮保持在 _centerView 下方。

我面临的问题是,当我在 _centerView 下方插入一个按钮时,我看到 _centerView 上出现闪烁(只是短暂的一瞬间)。我尝试了 sendSubviewToBack:insertSubview:belowSubview: - 相同的效果。

您知道哪些地方可能出了问题吗?我错过了什么吗?这是我的代码:

    UIButton* itemButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [itemButton setFrame:CGRectMake(0, 0, 40, 40)];
    [itemButton setCenter:_centerView.center];

    [parentView bringSubviewToFront:_centerView];
    [parentView insertSubview:itemButton belowSubview:_centerView];

最佳答案

我最近遇到了同样的问题,但将此选项传递给动画代码修复了它。希望这对你也有帮助。如果没有您的评论,我不会想出我的解决方案,所以谢谢您:)

UIViewAnimationOptionShowHideTransitionViews

关于iphone - sendSubviewToBack 和 insertSubview :belowSubview: don't work as they should 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11037478/

相关文章:

ios - 动态创建一个json对象

ios - 强制 Nib 加载器使用 init?(带有 :) for custom subclass of NSObject in iOS

c++ - 字典式查找对应于一小组值的数百万个键?

ios - MKCircle-添加/删除覆盖

ios - 屏幕左/左下角的 UINavigationController 和触摸事件

iphone - NSFileManager 监视目录

iphone - 更好的方法 - 为 iPad 应用程序使用数据库或网络服务

iphone - 这种在 Xcode 4 中重新引用另一个项目的方法有什么问题?

iphone - 两个 Objective-C 内存管理问题 : Is Leak Detection Always Right? 和为什么 autorelease 工作但不释放?

iphone - 是否有 "Find My iPhone?"的 iOS 配置文件 key