gpt4 book ai didi

uitableview - 如何更改 View 中每个 UIButton 的框架

转载 作者:行者123 更新时间:2023-11-29 11:24:14 24 4
gpt4 key购买 nike

当设备的方向更新时,我正在尝试为分配的 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/

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