【问题标题】:Button not showing up after "unhiding" it“取消隐藏”后按钮未显示
【发布时间】:2010-05-18 15:21:19
【问题描述】:

大家好 - 我似乎无法弄清楚我在这里做错了什么。我在我的 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;


}

有什么想法吗?提前致谢!

【问题讨论】:

    标签: iphone iphone-sdk-3.0 uibutton


    【解决方案1】:

    确保您在主线程上调用unhideShowtimesButton

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

    anObject 是你正在解析的对象,如果它在按钮的同一个对象中,请使用self

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

    【讨论】:

    • 嗯...仍然无法成功。当我有更多的空闲时间来处理它时,我将不得不在这里再试一次。感谢您的帖子!
    猜你喜欢
    • 1970-01-01
    • 2021-06-05
    • 1970-01-01
    • 2013-11-18
    • 1970-01-01
    • 1970-01-01
    • 2021-11-27
    • 2012-01-19
    • 2021-06-14
    相关资源
    最近更新 更多