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

标签 uitableview ios ios4 uibutton

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

相关文章:

ios - AutoLayout 标签在屏幕右侧被截断

ios - iPad 应用程序在 iOS 10 中将应用程序图标显示为启动屏幕

iphone - 重新验证收据

video - UIWebView iPhone OS 4.0无法查看YouTube视频

ios - 如何在 UITableView 的选定单元格行中设置图像

uitableview - 如何从 Storyboard中的 didSelectRowAtIndexPath 打开 View Controller ?

iphone - 横向/纵向冲突 - iOS

iphone - 将图层阴影裁剪为宽度而不是高度?

iphone - 将核心数据从一个项目传输到另一个项目

ios - 无法在 IOS8 中使用 showSegue 以编程方式 "push"viewcontroller