当设备的方向更新时,我正在尝试为分配的 UIButton 更新每一帧。现在我有一个 for 循环,它应该检查 View 中的每个 UIButton 并更新 UIButton 的框架。但是 for 循环不起作用,谁能告诉我为什么?
提前致谢!
for(UIView* view in theTable.subviews) {
if([view isMemberOfClass:[UIButton class]]) {
NSLog(@"UIButton found");
view.frame = CGRectMake(430, 10, 23, 24);
}
}
最佳答案
尝试在更改框架后调用 [view setNeedsDisplay];
。来自文档:
You can use this method or the setNeedsDisplayInRect: to notify the system that your view’s contents need to be redrawn. This method makes a note of the request and returns immediately. The view is not actually redrawn until the next drawing cycle, at which point all invalidated views are updated.
关于uitableview - 如何更改 View 中每个 UIButton 的框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4418753/