why need remove/add a NSView after it's reassigned to make it displayed

I found that when I reassign a NSView(viewA aleardy added into superView) to another view(new viewB) , as below:

viewA = [[NSView alloc] init];
viewB = [[NSView alloc] init];
[self.view addSubview ViewA];
veiwA = viewB;

viewB will not be updated into superView, event I try the following methods:

1)

[viewA setHidden: YES];
[viewA setHidded: NO];

2) [viewA setNeedLayout: YES];

Only to removew viewA and re-add it back to it's superview will work:

[viewA removeFromSuperView];
[self.view addSubview:viewA];

Could anybody help to explain why method 1) and 2) cannot update the rect of viewA ?

0 Comment

NO COMMENTS

LEAVE A REPLY

Captcha image