UIActivity 指示器在 iPhone 4(视网膜)上不起作用

发布于 2024-10-14 21:06:02 字数 105 浏览 5 评论 0原文

我有一个 UIActivityIndi​​cator,它在 iPhone 3G 模拟器/设备上运行良好,但在 iPhone 4(Retina) 模拟器/设备上不起作用。我想提一下,它是黑色背景的。

I have an UIActivityIndicator which is working as well as good in iPhone 3G simulator/device, but it is not working on Simulator/Device for iPhone 4(Retina). I would like to mention that it is on a black background.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你怎么这么可爱啊 2024-10-21 21:06:02

我以前也遇到过类似的问题。通过将指示器样式更改为 UIActivityIndi​​catorViewStyleWhiteLarge 并为背景提供对比色(我选择黑色)来解决此问题。问题实际上是它不可见。

I had a similar problem sometime back. It was solved by changing the indicator style to UIActivityIndicatorViewStyleWhiteLarge and giving a contrasting color(I chose black) to the background. The problem actually is that it's not visible.

请止步禁区 2024-10-21 21:06:02

UIActivityIndi​​cator 不会立即显示。

如果您有这样的代码:

//(pseudo-code)
//Create UIActivityIndicator
//show UIActivityIndicator
//do some other stuff expecting view to show

UIActivityIndi​​cator 将不会显示,因为 UIActivityIndi​​cator 只会在程序的下一个运行循环中显示。

您可以通过以下方法解决此问题:

{
    //create UIActivityIndicator
    //show UIActivityIndicator
    [self performSelector:@selector(doOtherStuff) withObject:nil afterDelay:0];
}

-(void)doOtherStuff {
    //do stuff 
}

performSelector 意味着 doOtherStuff 将在下一个运行循环中执行,此时 UIActivityIndi​​cator 将显示。

您还必须将其作为子视图添加到您希望其显示的视图中。

The UIActivityIndicator will not show up immediately.

If you have code such as this:

//(pseudo-code)
//Create UIActivityIndicator
//show UIActivityIndicator
//do some other stuff expecting view to show

the UIActivityIndicator will not show up, as the UIActivityIndicator will only show on the next run loop of the program.

You can get around this by

{
    //create UIActivityIndicator
    //show UIActivityIndicator
    [self performSelector:@selector(doOtherStuff) withObject:nil afterDelay:0];
}

-(void)doOtherStuff {
    //do stuff 
}

The performSelector means that the doOtherStuff is performed on the next run loop, when the UIActivityIndicator will show.

You also have to add it as a subview to the view in which you want it to show.

靑春怀旧 2024-10-21 21:06:02

也许您正在从非主线程的线程显示微调器?您可以尝试这个断言来确定您是否在主线程上:

NSAssert([[NSThread currentThread] isMainThread],
    @"This should be run from the main thread.");

如果断言失败,您可以将调用分派到主线程:

dispatch_async(dispatch_get_main_queue(), ^{
    // display the spinner
});

无论如何,在没有看到代码的情况下我们都只是猜测。

Maybe you’re displaying the spinner from a thread that’s not the main thread? You can try this assert to find out whether you’re on the main thread:

NSAssert([[NSThread currentThread] isMainThread],
    @"This should be run from the main thread.");

If the assert fails, you can dispatch the call to the main thread:

dispatch_async(dispatch_get_main_queue(), ^{
    // display the spinner
});

Anyway, without seeing the code we are all just guessing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文