开发者

self.window addSubview not working properly

开发者 https://www.devze.com 2023-04-12 18:16 出处:网络
I am trying to call a new view to come on top of the current one. The code 开发者_开发百科in the appDelegate.h is:

I am trying to call a new view to come on top of the current one. The code 开发者_开发百科in the appDelegate.h is:

-(void)switchToTransferFundsView {
    if(!objTransferFunds) {

        objTransferFunds = [[TransferFunds alloc]initWithNibName:@"TransferFunds" bundle:nil];
        [self.window addSubview:objTransferFunds.view];
    }

}

The view does appear except it doesnt fully cover the view underneath it; theres a slight transformation. Can someone tell me why?


It seems to be an "autoResizingMask issue".

To be sure your frame won't change, set UIViewAutoresizingNone as value for your view property autoresizingMask.

One drawback, with this setting, is your view will not be adjusted automatically when rotation occurred for example.

For more information, see the documentation:

http://developer.apple.com/library/ios/documentation/uikit/reference/uiview_class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW6


Have you set the frame properly in the xib editer? In the attribute inspector set the x, y, width and height which you would like to set for your view. If this does not solve, give some more details of the issue.


As Krishna mentioned, you should check the frame settings in the inspector.

If that doesn't work, you might want to just use a work-around: account for the transformation. If your "transfer funds" view is shifted to the right from where you set it in the xib file, shift it to compensate.

0

精彩评论

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