iPhone SDK: How to trigger drawRect on UIView subclass after orientation change?

岁酱吖の 提交于 2019-11-28 09:43:44
[myView setContentMode:UIViewContentModeRedraw];

You can set this in IB as well (i.e., set mode to "redraw")

This was a bug related to something completely different. setNeedsDisplay does indeed cause drawRect to be called.

to answer this and the other 94,000 similiar questions about view rotation/drawrect funkiness,

-(id)initWithFrame:(CGRect)frame
{
    if(self=[super initWithFrame:frame]) {
        self.autoresizesSubviews=YES;
        self.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
    }
    return self;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!