Making view resize to its parent when added with addSubview

后端 未结 6 641
再見小時候
再見小時候 2020-12-29 21:35

I\'m having a problem when using addSubview.

Example code:

ParentView *myParentView = [[ParentView alloc] initWithNibName:@\"ParentView \" bundle:nil         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 22:27

    You can always do it in your UIViews - (void)didMoveToSuperview method. It will get called when added or removed from your parent (nil when removed). At that point in time just set your size to that of your parent. From that point on the autoresize mask should work properly.

提交回复
热议问题