开发者

Button not showing up after "unhiding" it

开发者 https://www.devze.com 2022-12-30 12:43 出处:网络
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 s

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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消