当用户选择UITable行时显示等待屏幕 [英] Display waiting screen when user selects UITable row

查看:125
本文介绍了当用户选择UITable行时显示等待屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户在我的表中选择一行时,我需要使用CoreData加载一堆数据。这需要几秒钟(至少在模拟器上运行时 - 还没有在设备上测试,但我想它仍然会很长)。我想显示一个加载弹出窗口(我正在开发的iPad),当用户选择一行,然后一旦数据加载消失。

When the user selects a row in my table, I need to load a bunch of data with CoreData. This takes several seconds (at least when running on the simulator - haven't tested on a device yet, but I imagine it will still be pretty long). I want to display a loading popover screen (I'm developing for iPad) when the user selects a row, then have it disappear once the data is loaded.

工作时与UIButtons,我一直这样做通过触发TouchDown和TouchUp方法。我把代码显示在TouchDown的popover,然后做所有我的实际工作(所以在这种情况下从CoreData加载)在TouchUp。然后在TouchUp结束时,我关闭弹出框。

When working with UIButtons, I've always done this by triggering both a TouchDown and TouchUp method. I put the code to display the popover on the TouchDown, then do all my actual work (so in this case loading from CoreData) in the TouchUp. Then at the end of TouchUp, I close the popover.

有没有办法在表格视图中分割触摸,与按钮上的触摸相同?

Is there a way to split up touches in a table view the same way as ones on a button?

推荐答案

所以,当我打字的问题,我遇到了一些在 willSelectRowAtIndexPath 的com / library / ios /#documentation / uikit / reference / UITableViewDelegate_Protocol / Reference / Reference.htmlrel =nofollow> Apple Docs 看起来像是解决这个问题。我没有看到任何其他主题在这上,所以我想我会使用这里回答自己的问题 - Q& A功能,所以也许人们寻找这个在未来会找到一点更容易。

So while I was typing up the question I came across something in the Apple Docs for willSelectRowAtIndexPath and it looks like that is there to address this very issue. I didn't see any other topics on this on SO, so I figured I'd make use of this "Answer own question - Q&A" feature on here, so maybe people looking for this in the future will find it a little easier.

巨大的FYI块:

willSelectRowAtIndexPath 实际上应该返回一个 NSIndexPath ,不像 didSelectRowAtIndexPath (返回 void )。但是,我原来有

I should note that willSelectRowAtIndexPath is actually supposed to return an NSIndexPath, unlike didSelectRowAtIndexPath (which returns void). However, I originally had

-(void)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //stuff
}

注意 void 返回类型。 Xcode(版本4.5)允许这没有任何错误或警告(甚至在我的自动完成列表中)。当我以这种方式运行代码时,我总是在 libobjc.A.dylib'objc_autorelease:中打上一个不可见的断点(也许因为我有所有异常断点启用?) 。我不能超过这个断点,我从来没有在调试器输出控制台中有任何调试信息,并且应用程序从未终止。我碰巧再次看看苹果文档,并注意到它应该返回一个NSIndexPath(具体来说,索引路径的代码应该解释为一个被选择的),但如果我没有碰巧看到它,我从来不知道这是什么问题。

Note the void return type. Xcode (Version 4.5) allowed this without any errors or warnings (and even had it for me in the autocomplete list). When I ran the code this way, I always hit an invisible breakpoint in libobjc.A.dylib'objc_autorelease: (maybe becaues I have the "All Exceptions" breakpoint enabled?). I couldn't get past this breakpoint, I never got any debug information in the debugger output console, and the app never terminated. I happened to look at the Apple Doc again and notice that it was supposed to return an NSIndexPath (specifically, the index path the code should interpret as being the one that was selected), but if I didn't happen to see it there, I never would have known what the problem was.

这篇关于当用户选择UITable行时显示等待屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆