“取消隐藏”后按钮不显示

时间:2010-05-18 15:21:20

标签: iphone iphone-sdk-3.0 uibutton

嘿大家 - 我似乎无法弄清楚我在这里做错了什么。我在rootviewcontroller中创建了一个按钮。我立即隐藏它,当我的解析器完成时,在一个单独的线程上启动我将它发送到一个“取消隐藏”我的按钮的方法。但是......它并非“取消隐藏”。

以下是我的RootViewController的ViewDidLoad中的内容

 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;

这是“取消隐藏”它的方法。我在这个方法上休息一下,所以我知道我已经开始了。

-(void)unhideShowtimesButton {

 showtimesButton.hidden = NO;


}

任何想法?提前谢谢!

1 个答案:

答案 0 :(得分:2)

确保您在主线程上调用unhideShowtimesButton

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

其中anObject是您正在进行解析的对象,如果它位于按钮的同一对象中,请使用self

除了主线程之外,您无法与UI元素进行交互。

相关问题