Action from different XIB
I am trying to do a action from a different XIB and class. I have been staring at this code for days, yes, days. Please help! Below is some code.
CaptionView.h file
#import "processViewController.h"
CaptionView.m file
processViewController *test = [[processViewController alloc] init];
[test startUploads];
processViewController.m
- (IBAction)startUploads {
[NSThread detachNewThreadSelector:@selector(startUploadsTwo) toTarget:self withObject:nil];
}
- (IBAction)startUploadsTwo {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NS开发者_开发技巧AutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
... code...
[pool release];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
For some reason the action is not being called. Any help is appreciated! - Coulton
If I'm not mistaken, you can't update the UI from worker threads. For this reason, you should change the networkIndicator
from the main thread.
You can still trigger this from the worker though, using this method:
[self performSelectorOnMainThread:@selector(updateSpinner:)
withObject:nil
waitUntilDone:false];
From the docs:
The main thread encompasses the application’s main run loop, and is where the NSApplication object receives events.
This quotation refers to NSApplication
, which is for OSX, but I imagine the same applies for UIApplication
on iOS. Can't find an actual quote though.
精彩评论