改变视图的问题

发布于 2024-10-28 06:25:02 字数 1056 浏览 1 评论 0原文

您好,我有一个问题,我创建了一个基于苹果示例应用程序的应用程序,名为 photoscroller,我想添加一个登录屏幕。但是当我添加它时,显示的视图向上移动 10-15 像素,并且主窗口在下面可见。我问为什么?

我的部分代码:

在视图中确实加载了:

    InfoViewController *infoView =  [[InfoViewController alloc] initWithNibName:nil bundle:nil];
    self.view = infoView.view;
    [infoView release];

然后在验证登录后:

    CGRect pagingScrollViewFrame = [self frameForPagingScrollView];
    pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame];
    pagingScrollView.pagingEnabled = YES;
    pagingScrollView.backgroundColor = [UIColor blackColor];
    pagingScrollView.showsVerticalScrollIndicator = NO;
    pagingScrollView.showsHorizontalScrollIndicator = NO;
    pagingScrollView.contentSize = [self contentSizeForPagingScrollView];
    pagingScrollView.delegate = self;
    self.view = pagingScrollView;
...

我不知道为什么当我添加其他视图时被向上推。

感谢每一个答案

hi I have a problem I made an application based on apples sample app called photoscroller and i want to add a login screen.but when i add it the showed view move upward 10-15 pixels and the main window is visible underneath.I ask why?

Parts of my code:

at view did load:

    InfoViewController *infoView =  [[InfoViewController alloc] initWithNibName:nil bundle:nil];
    self.view = infoView.view;
    [infoView release];

then later after validating the login:

    CGRect pagingScrollViewFrame = [self frameForPagingScrollView];
    pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame];
    pagingScrollView.pagingEnabled = YES;
    pagingScrollView.backgroundColor = [UIColor blackColor];
    pagingScrollView.showsVerticalScrollIndicator = NO;
    pagingScrollView.showsHorizontalScrollIndicator = NO;
    pagingScrollView.contentSize = [self contentSizeForPagingScrollView];
    pagingScrollView.delegate = self;
    self.view = pagingScrollView;
...

I do not know why is pushed upward when i add other view.

thank for every answer

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失而复得 2024-11-04 06:25:02

您可以通过方法-(CGRect)frameForPagingScrollView吗?如果没有该方法,理解您的代码会有点困难。

但我猜想 self.view.frame 和从该方法返回的 CGRect 不同。
进一步的猜测是,差异不是 10-15 像素,而是 20 像素(UIStatusBar 的高度),这可能在您的 .xib 文件中启用,但实际上并未显示。

Could you past the method - (CGRect) frameForPagingScrollView, without that method it's bit harder to understand your code.

But i guess the self.view.frame and the CGRect returned from that method differ.
Further guess would be, that the difference are not 10-15 pixels, but 20 pixels (for the height of the UIStatusBar), which might be enabled in your .xib-File but is actually not displayed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文