开发者

Incorrect y position for objects inside UIViewController's view

开发者 https://www.devze.com 2023-01-31 00:14 出处:网络
I created programmatically a multi view iphone application. when adding objects to a view, like a button for ex开发者_运维知识库ample. in position x = 0, y = 0

I created programmatically a multi view iphone application.

when adding objects to a view, like a button for ex开发者_运维知识库ample. in position x = 0, y = 0 this results to x = 0, y = 20 in the iphone simulator.

this is the used code :

UIButton *btnGoToStartView = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
btnGoToStartView.frame = CGRectMake(0, 0, 240, 30);
[btnGoToStartView setTitle:@"Btn Name" forState:UIControlStateNormal];
[btnGoToStartView addTarget:self action:@selector(myBtnAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnGoToStartView];

In the other hand, when I'm placing a button using Interface Builder in position x = 0, y = 0 the result is good.

Till now I didn't found the real reason for this vertical shifting. Thanks in advance for your hints.

Regards.


It's Ok, I found the solution.

It's a problem of the UIView not the control.

in Interface builder, I opened the MainWindow.xib then I modified the attribute Layout in the inspector window.

I checked [wants full screen].

That's all.

0

精彩评论

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