views:

60

answers:

1

Hey everyone - I cant seem to figure out what i am doing wrong here. I create a button in my rootviewcontroller. I immediately hide it, when my parser is done that was started on a seperate thread I send it to a method that "unhides" my button. But... its not "unhiding" it.

Here is what i have in my ViewDidLoad of my RootViewController

 showtimesButton = [UIButton buttonWithType:UIButtonTypeCustom];
 image = [UIImage imageNamed:@"homeshowtimes.png"];
 [showtimesButton setBackgroundImage:image forState:UIControlStateNormal];
 showtimesButton.frame = CGRectMake(27, 390, 265, 63);
 [showtimesButton addTarget:self action:@selector(showtimesButtonPressed) forControlEvents:UIControlEventTouchUpInside];
 [self.view addSubview:showtimesButton];
 showtimesButton.hidden = YES;

and here is the method that is "unhiding" it. I put a break in this method so i know i am getting to it.

-(void)unhideShowtimesButton {

 showtimesButton.hidden = NO;


}

any thoughts? thanks in advance!

+1  A: 

Make sure you're calling unhideShowtimesButton on the main thread:

[anObject performSelectorOnMainThread:@selector(unhideShowtimesButton) withObject:nil waitUntilDone:NO];

Where anObject is the object you're doing the parsing in, if it's in the same object at the button, use self

You can't interact with UI elements on anything other than the main thread.

Tom Irving
Hmm... still not able to pull it off. I will have to try again here in a minute when I get a little more free time to mess with it. Thanks for the post!
Louie