【问题标题】:How to put a UIView all time on top screen?如何始终将 UIView 放在顶部屏幕上?
【发布时间】:2012-06-11 21:14:23
【问题描述】:

我将在我的调试模式程序中显示一个 UITextView,其中包含来自 NSLog 的所有消息。它有效,但我的问题是:我必须一直展示它。那么,我怎样才能让我的视图在我的程序中一直显示,看起来像状态栏?

【问题讨论】:

    标签: iphone ios uiview uiwindow


    【解决方案1】:

    在你的didFinishLaunchingWithOptions

    设置以下

    //Add the textView to the rootviewcontroller view
    UITextView *textView = [[UITextView alloc] init];
    textView.frame = CGRectMake(0, 20, 320, 40);
    [self.window.rootViewController.view addSubview:textView];
    

    【讨论】:

    • 太棒了!这是我的错误:rootViewController!!!我不使用它。我只是得到顶部的 UIWindow,但必须得到 rootViewController。谢谢。
    • 如果正在呈现模态视图控制器,这将不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多