在弹出窗口的选项卡栏中的导航控制器中取消 UITableView 搜索后,UINavigationBar 无响应

发布于 2024-09-13 02:08:54 字数 1670 浏览 1 评论 0原文

好吧,这是一个奇怪的问题,我可以轻松地用一个新项目重现它。

设置如下:
我有一个 UISplitViewController。在左侧我有一个 UITabBarController。在此选项卡栏控制器中,我有两个 UINavigationController。在导航控制器中,我有 UITableViewControllers。这些表格视图上有搜索栏。

好的,此设置会发生的情况是,如果我处于纵向模式并在弹出窗口中调出此视图,然后我在其中一个表格视图中开始搜索并取消它,导航栏将变得无响应。也就是说,“后退”按钮以及右侧按钮都无法点击。

如果我在横向模式下执行完全相同的操作,这样我们就不会处于弹出窗口中,这种情况就不会发生。导航栏保持响应。

因此,问题似乎只发生在弹出窗口内。

我还注意到,如果我进行搜索但单击搜索结果中的某个项目,最终会将某些内容加载到拆分视图的“详细信息视图”中并关闭弹出窗口,然后返回到弹出窗口,然后单击搜索的取消按钮,导航栏是响应式的。

我的应用程序是一个通用应用程序,在 iPhone 界面中使用相同的选项卡栏控制器,并且它可以正常运行而不会出现此问题。


正如我上面提到的,我可以轻松地用一个新项目重现这一点。如果您想自己尝试一下,请执行以下步骤:

  • 启动新项目 - 拆分视图

  • 创建新的 UITableViewController 类(我命名为 TableViewController)

    • 取消注释 viewDidLoad 方法以及 viewDidLoad 中的 rightBarButtonItem 行(这样我们将在导航栏中有一个“编辑”按钮)

    • 输入您想要从 numberOfSectioinsInTableView 和 numberOfRowsInSection 方法返回的任何值

  • 打开 MainWindow.xib 并执行以下操作:

    • 请注意,您需要在中间的“查看模式”下查看 xib,以便可以展开项目的内容

    • 将选项卡栏控制器拖到 xib 中以替换导航控制器项

    • 将导航控制器拖到 xib 中,作为选项卡栏控制器下的另一个项目

    • 删除选项卡栏控制器下的其他两个视图控制器(因此,现在我们的选项卡栏上只有一个导航控制器)

    • 在导航控制器内,拖入一个表视图控制器并用它来替换视图控制器(根视图控制器)

    • 将新的表视图控制器的类更改为上面创建的类(对我来说是TableViewController)

    • 双击新表视图控制器下的表视图将其打开(将显示在拆分视图控制器内的选项卡栏中)

    • 将“搜索栏和搜索显示”拖到表格视图上

    • 保存 xib

    • 在模拟器中运行项目

      • 在纵向模式下,单击“根列表”按钮可弹出弹出窗口

      • 注意“编辑”按钮是可点击的

      • 点击搜索框 - 我们进入搜索模式

      • 单击“取消”按钮退出搜索模式

      • 请注意“编辑”按钮不再起作用


所以,任何人都可以帮我弄清楚为什么会发生这种情况?

谢谢,

马克

Ok, this is an odd one and I can reproduce it with a new project easily.

Here is the setup:
I have a UISplitViewController. In the left side I have a UITabBarController. In this tab bar controller I have two UINavigationControllers. In the navigation controllers I have UITableViewControllers. These table views have search bars on them.

Ok, what happens with this setup is that if I'm in portrait mode and bring up this view in the popover and I start a search in one of the table views and cancel it, the navigation bar becomes unresponsive. That is, the "back" button as well as the right side button cannot be clicked.

If I do the exact same thing in landscape mode so we are not in a popover, this doesn't happen. The navigation bar stays responsive.

So, the problem only seems to happen inside a popover.

I've also noticed that if I do the search but click on an item in the search results which ends up loading something into the "detail view" of the split view and dismissing the popover, and then come back to the popover and then click the Cancel button for the search, the navigation bar is responsive.

My application is a universal app and uses the same tab bar controller in the iPhone interface and it works there without this issue.


As I mentioned above, I can easily reproduce this with a new project. Here are the steps if you want to try it out yourself:

  • start new project - split view

  • create new UITableViewController class (i named TableViewController)

    • uncomment out the viewDidLoad method as well as the rightBarButtonItem line in viewDidLoad (so we will have an Edit button in the navigation bar)

    • enter any values you want to return from numberOfSectioinsInTableView and numberOfRowsInSection methods

  • open MainWindow.xib and do the following:

    • please note that you will need to be viewing the xib in the middle "view mode" so you can expand the contents of the items

    • drag a Tab Bar Controller into the xib to replace the Navigation Controller item

    • drag a Navigation Controller into the xib as another item under the Tab Bar Controller

    • delete the other two view controllers that are under the Tab Bar Controller (so, now our tab bar has just the one navigation controller on it)

    • inside the navigation controller, drag in a Table View Controller and use it to replace the View Controller (Root View Controller)

    • change the class of the new Table View Controller to the class created above (TableViewController for me)

    • double-click on the Table View under the new Table View Controller to open it up (will be displayed in the tab bar inside the split view controller)

    • drag a "Search Bar and Search Display" onto the table view

    • save the xib

    • run the project in simulator

      • while in portrait mode, click on the Root List button to bring up popover

      • notice the Edit button is clickable

      • click in the Search box - we go into search mode

      • click the Cancel button to exit search mode

      • notice the Edit button no longer works


So, can anyone help me figure out why this is happening?

Thanks,

Mark

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

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

发布评论

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

评论(2

删除会话 2024-09-20 02:08:54

好的,已从 Apple 开发者技术支持处得到答复。他们对此进行了调查,发现这是 UIPopoverController 中的一个错误。他给了我一个可行的解决方法,但在取消搜索后,导航栏中的右侧按钮最终会滑过屏幕。但是,至少它解决了这个问题。他还建议我向 Apple 发送错误报告,我也这样做了。希望他们能在下一版本的 SDK 中解决这个问题。

以下是苹果工程师回复的相关部分的副本:

我已经创建了自己的项目并深入研究了正在发生的事情,看起来这是 UIPopoverController 中的一个错误,在 UISearchBar 被关闭后,导航栏中的某些内容被阻塞。

我现在找到了一个解决方法,尽管出现的动画并不是非常理想:
- 使用UISearchBarDelegate的-searchBarCancelButtonClicked:方法并添加以下内容:

self.navigationItem.rightBarButtonItem = nil;
self.navigationItem.rightBarButtonItem = self.editButtonItem;

正如我所说,看起来弹出窗口正在将按钮推到导航栏上,因此它可能不是您正在寻找的内容。

Ok, got an answer from Apple Developer Technical Support. They investigated it and found it is a bug in the UIPopoverController. He gave me a workaround that kind of works but the right button in the nav bar ends up sliding across the screen after canceling the search. But, at least it fixes the issue. He also suggested I send in a bug report to Apple and I've done that as well. Hopefully they will fix this in the next version of the SDK.

Here's a copy of the relevant portion of the Apple engineer's response:

I've created my own project and dipped into what is going on and it looks like it's a bug in the UIPopoverController where after the UISearchBar is being dismissed, something is being obstructed in the navigation bar.

There's a workaround that I've found for now, though the animation that occurs is not amazingly optimal:
- Use the – searchBarCancelButtonClicked: method of UISearchBarDelegate and add the following:

self.navigationItem.rightBarButtonItem = nil;
self.navigationItem.rightBarButtonItem = self.editButtonItem;

As I said, it looks like the popover is pushing the button onto the navigation bar, so it may not be what you're looking for.

橘虞初梦 2024-09-20 02:08:54

我尝试了提到的 rightBarItem 技术,但它对我不起作用。我必须这样做(这实际上也是一种黑客行为)

[self.navigationController setNavigationBarHidden:YES animated:NO];
[self.navigationController setNavigationBarHidden:NO animated:NO];

这可能是因为我的 UINavigationBar 不是与弹出窗口统一的,但我不能肯定地说。

I tried the rightBarItem technique mentioned, but it didn't work for me. I had to do this (which is also a hack really)

[self.navigationController setNavigationBarHidden:YES animated:NO];
[self.navigationController setNavigationBarHidden:NO animated:NO];

This might be because my UINavigationBar isn't one unified with the popover, but I can't say for sure.

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