开发者

How to change frame for each UIButton in view

I'm trying to update every frame for an allocated UIButton when the device's orientation is updated. Right now I have a for loop that's supposed to check for every UIButton in the view and update the frame of the UIButton. The for loop is not working though, can anyone tell me why?

Thanks in advance!

for(UIView* view in theTable.subviews) {
    if([view isMemberOfClass:[UIButton class]]) {
        NSLog(@"UIButton found");
        view.frame = CGRectMake(430, 10, 23, 24)开发者_运维问答;
    }
}


Try calling [view setNeedsDisplay]; after changing the frame. From the documentation:

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜