Automatically Sizing UIView after Adding to Window

前端 未结 6 909
孤街浪徒
孤街浪徒 2020-12-16 06:41

Note: This may be a duplicate of Subview Doesnt AutoSize When Added to Root View Controller


I have an iPad app that switches between different views in its mai

6条回答
  •  情歌与酒
    2020-12-16 06:56

    I got the same problem, but i fixed it with this lines of code:

    - (void)changeRow:(NSNotification *)notification {
    [window addSubview:new.view];
    [old.view removeFromSuperview];
    [new.view removeFromSuperview];
    [window addSubview:new.view];
    

    }

    You must add the new view, then remove the old and the new and then add the new view. I don't know why, but that works.

提交回复
热议问题