ios - 缺少 "master"按钮和滑动手势不起作用主/详细 ios
<p><p>我创建了 Master detail 应用程序,其中包含多个通过替换 segue 连接到 Split View的详细 ViewController 。在横向上一切正常,但在纵向上我缺少打开主表格 View 和在屏幕左侧滑动的按钮不起作用,也没有打开应用程序的主侧。</p>
<p><strong>编辑:</strong> </p>
<p>在我的 DetailViewController 中,我有两种方法,与 xcode 为 master-detail 应用程序提供的模板中相同:</p>
<pre><code>#pragma mark - Split view
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem.title = NSLocalizedString(@"MasterButton", @"Master");
;
self.masterPopoverController = popoverController;
}
- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
// Called when the view is shown again in the split view, invalidating the button and popover controller.
;
self.masterPopoverController = nil;
}
</code></pre>
<p><strong>编辑 2:</strong>
在更改我的 detailViewController 时,我也更改了委托(delegate)。</p>
<pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UIViewController *destinationViewController = ;
if () {
self.splitViewController.delegate = (id)destinationViewController;
}
else {
self.splitViewController.delegate = nil;
}
}
</code></pre>
<p><strong>编辑 3:</strong>
我终于通过在我创建的每个 DetailViewController 中添加这行代码来解决我的问题:</p>
<pre><code>self.splitViewController.delegate = self;
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你需要放置 <code>barButtonItem</code> from</p>
<p><code>- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc</code></p>
<p>在细节 ViewController 的导航栏。</p></p>
<p style="font-size: 20px;">关于ios - 缺少"master"按钮和滑动手势不起作用主/详细 ios,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/20188486/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/20188486/
</a>
</p>
页:
[1]