【问题标题】:Forced Updated Display view controller from .xib从 .xib 强制更新显示视图控制器
【发布时间】:2015-07-30 12:46:30
【问题描述】:

我正在尝试显示来自 .xib 的视图控制器,该控制器向用户指示应用程序的更新可用。出于某种原因,以下代码似乎什么都不做:

if ([serverObject[@"newServerBuilt"] isEqualToString:@"YES"])    {


                //we want to display the text from the server to user
                NSString * displayText=serverObject[@"displayText"];

                ForceUpdate * forceUpdateViewController = [[ForceUpdate alloc] initWithNibName:@"ForceUpdate" bundle:nil];

                forceUpdateViewController.textToShow=displayText;

                [self presentViewController:forceUpdateViewController    animated:NO completion:nil];
}

有人知道为什么吗?如您所见,我允许自己根据服务器上的可自定义消息显示更新视图控制器。

另外,当我点击 .xib 中的文本标签时,它说文本标签连接到“文件的所有者”,但它应该连接到“强制更新”吗?

强制 update.h 看起来像这样:

#import <UIKit/UIKit.h>

@interface ForceUpdate : UIView

@property (nonatomic, strong) NSString * textToShow;

@end

【问题讨论】:

    标签: objective-c uiview uiviewcontroller xib


    【解决方案1】:

    我猜你会在AppDelegate.m 文件中这样做。如果YES 那么你需要从[[[UIApplication sharedApplication] keyWindow] rootViewController] 插入ViewController self

    [[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:forceUpdateViewController    animated:NO completion:nil];
    

    【讨论】:

      猜你喜欢
      • 2016-06-14
      • 1970-01-01
      • 1970-01-01
      • 2017-04-05
      • 1970-01-01
      • 2010-09-19
      • 1970-01-01
      • 2016-05-09
      • 1970-01-01
      相关资源
      最近更新 更多