我在其他视图之间有一个视图,顺序可能会有所不同。例如: viewA在viewB之上,在viewC之上,或者以另一种顺序。
假设我有
viewA、viewB、viewC、viewD和viewE
A在顶部,E在底部。
我需要用viewZ替换viewC,但我需要在viewC的相同索引中插入viewZ。
在删除viewC之前,我如何知道它有什么索引,所以我可以使用以下命令插入viewZ
[self.view insertSubview:viewZ atIndex:?????)它会处于相同的水平吗?
谢谢你的帮助。
发布于 2010-06-18 10:19:18
来自How to get UIView hierarchy index ??? (i.e. the depth in between the other subviews)
int index = [[superView subviews] indexOfObject:viewC];发布于 2010-06-18 16:25:40
除了获取索引之外,您还可以使用-insertSubview:aboveSubview: (和…belowSubview:):
UIView* superview = self.view;
[superview insertSubview:viewZ aboveSubview:viewC];
[viewC removeFromSuperview];https://stackoverflow.com/questions/3066815
复制相似问题