Buggy 导航控制器,将 iPhone 应用程序移植到 iPad
我有一个相当简单的 iPhone 应用程序,我想在 iPhone 和 iPad 上运行它。我想让 iPad 版本成为 iPhone 版本的更大版本,无论是否放大——我正在开发该应用程序的 iPad 专用版本,可以更好地利用界面,但希望确保我现有的客户在此期间有一些东西。
该应用程序是一个简单的基于选项卡的应用程序,每个选项卡内都有一个呈现表格视图的导航控制器,每个视图都可以向下钻取几个层。一切都基本正常——我有几个视图实例没有填充可用空间,但我可以解决这个问题。我现在最大的问题是,当我尝试使用导航控制器时,它们普遍会损坏。一旦我向下钻了一两层,我突然就再也回不来了。
让我尝试更详细地解释一下:
一个选项卡以“年”表视图开始,显示有条目的所有年份;如果您点击一年,它会推送另一个表格视图,其中包含该年中包含条目的所有月份;如果您点击一个月,它会推送另一个显示各个条目的表格视图;如果您点击一个条目,它会推送一个显示条目详细信息的视图(UIWebView
,带有一些额外的小部件)。
每次推送都是通过 [self.navigationController PushViewController: fooAnimated:YES]
完成的。我上面提到的三个表视图控制器都是从同一个笔尖创建的(事实上,推送到任何选项卡中导航控制器上的所有内容都是从同一个笔尖加载的)。因为我知道最多只有三个导航级别,所以我只分配了三个相同的视图控制器,并根据条目的数量使用一个、两个或三个。
使用“后退”按钮弹出这些控制器似乎普遍会弄乱视图控制器的状态。因此,如果我深入到第三个视图(显示一个月内的所有内容),我将无法一路弹出回到第一个视图:如果我弹出一个级别,后退按钮将停止工作。
另一个选项卡中的另一个示例:它是一个表视图,您可以点击其中的任何条目,并且将推送一个新的视图控制器来显示该条目的详细信息。如果我点击某个条目,点击后退按钮,然后再次点击该条目,不会出现后退按钮,或者有时会出现后退按钮内的文本,但没有出现任何按钮!
如果我尝试在缩放模式(使用基础 SDK 4.0 构建,支持 OS 3.2)或本机模式(使用基础 SDK 3.2 构建)下运行 iPhone 应用程序,则会发生此行为。它在 iPhone 上运行没有问题。我在这里有点不知所措,因为这些东西总是“开箱即用”,主要来自我第一次创建项目时设置的默认值。
我的程序员的直觉告诉我,我在视图导航中做了一些非常错误的事情,iPad 只是暴露了它,但我不知道它是什么。
有没有人遇到过这样的问题,或者提出可能的问题或更好的方法来调试正在发生的事情?
I have a fairly simple iPhone application that I want to have run on both the iPhone and the iPad. I'd like to just have the iPad version be a bigger version of the iPhone version, scaled up or not -- I'm working on an iPad-specific version of the app that makes better use of the interface, but wanted to make sure my existing customers have something in the meantime.
The app is a simple tab-based application, and within each tab is a navigation controller that presents a table view, each of which can drill down a couple of layers. Everything mostly works -- I have a couple of instances of views not filling the space available, but I can fix that. My biggest problem right now is that the navigation controllers universally break when I try using them. Once I drill down a level or two, I suddenly won't be able to come back up again.
Let me try to explain in more detail:
One tab starts off with a "year" table view, showing all years that have entries; if you tap a year, it pushes another table view with all months in that year that have entries; if you tap a month, it pushes another table view that shows the individual entries; if you tap an entry, it pushes a view (a UIWebView
, with some extra widgets) that shows an entry's details.
Each push is done with [self.navigationController pushViewController: foo animated: YES]
. The three table view controllers I mentioned above are all created from the same nib (in fact, everything pushed onto a navigation controller in any tab is loaded from the same nib). Since I know there are only up to three levels of navigation, I just allocated three identical view controllers and use one, two, or three depending on how many entries there are.
Popping these controllers off using the "back" button seems to universally mess up the state of the view controller. So, if I drill down to the third view -- showing everything in a single month -- I won't be able to pop all the way back up to the first view: the back button stops working if I pop up one level.
Another example in another tab: it's one table view that you can tap any entry on, and a new view controller will be pushed that shows the details of that entry. If I tap an entry, tap the back button, then tap the entry again, no back button appears, or sometimes, the text that would go inside the back button appears, but no button appears!
This behavior happens if I try running the iPhone app in scaled mode (built with base SDK 4.0, supporting OS 3.2) or in native mode (built with base SDK 3.2). It runs without problems on the iPhone. I'm kind of at a loss here, because this stuff always "just worked" out of the box, mostly from the defaults that were set up back when I first created the project.
My programmer's instincts are telling me that I'm doing something very wrong in my view navigation, and that the iPad is just exposing it, but I can't figure out what it is.
Has anyone run into an issue like this, or suggest something it might be or some better way to debug what's going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是我在 NSMutableArray 上有一个类别,它添加了类似堆栈的方法
push
和pop
。删除此类别解决了此问题。WTF,不过。
The issue was that I had a category on NSMutableArray, which added stack-like methods
push
andpop
. Removing this category class fixed this issue.WTF, though.