【问题标题】:Load data after the download from an NSThread in another class从另一个类中的 NSThread 下载后加载数据
【发布时间】:2011-04-07 18:12:51
【问题描述】:

在我的 AppDelegate 中,在初始屏幕期间,我启动了一个 NSThread,它从 Internet 下载数据。 当 NSThread 完成后,我删除了启动画面。

我需要在启动画面后显示的视图,使用下载的数据。 问题是方法

viewWillAppear

viewDidLoad

在 NSThread 期间被调用...并且应用程序可能会因为数据未完全下载而崩溃!

这是我的代码(在 appdelegate.m 中)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   
      //...
      //... 
      NSThread* parse_thread = [[NSThread alloc] initWithTarget:self selector:@selector(carica_dati)  object:nil];
     [parse_thread start];
     return YES;
}

-(void)carica_dati{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
   [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
   //download data, then remove the splash screen
   [pool release];
   [NSThread exit];
}

我该如何解决? NSThread 完成时是否可以调用一个方法(但我需要在另一个类中调用它,我的视图类)?

谢谢!

【问题讨论】:

  • 好的,抱歉!解决了!我在 nsthread 之后添加主视图[self.windows addSubview:tabbar.view]

标签: iphone xcode uitabbarcontroller nsthread


【解决方案1】:

;)

在nsthread之后添加主视图[self.windows addSubview:tabbar.view]!

;)

【讨论】:

    猜你喜欢
    • 2012-12-17
    • 1970-01-01
    • 1970-01-01
    • 2016-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多