如何使用Xcode Storyboards创建Popovers [英] How to create Popovers with Xcode Storyboards

查看:104
本文介绍了如何使用Xcode Storyboards创建Popovers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在适用于iOS 5.0+应用的iPad Storyboard中创建弹出窗口?

How can I create a popover in an iPad Storyboard for an iOS 5.0+ app?

已经有一个使用Xcode项目模板(Utility App)的设置,但是我似乎无法弄清楚Apple如何让它发挥作用。我试图模仿它,但只有错误。我甚至看过Apple的开发网站,但只得到过时的代码导致警告和构建错误。

There's already one setup with the Xcode Project Template (Utility App), but I can't seem to figure out how Apple got it to work. I tried to mimic it, but only got errors. I even looked on Apple's Dev Site, but only got out-dated code that resulted in warnings and build errors.

我有一个 CBMainView 和一个 CBMasterView (已包含主视图除外)和一个 UIToolbar a UIToolbarButton 。我需要用户点击 UIToolbar 上的按钮,然后我的320x300 Popover( CBMasterView )。

I have a CBMainView and a CBMasterView (with the exception of the master view already included), and a UIToolbar with a UIToolbarButton. I need the user to tap the button on the UIToolbar, and up comes my 320x300 Popover (CBMasterView).

如何使用Xcode Storyboards执行此操作?教程,答案,代码或链接都很受欢迎!

How can I do this with Xcode Storyboards? Tutorials, answers, code, or links are all appreciated!

推荐答案

在iOS 5之前,人们需要显示另一个 UIViewController 通过Modal演示文稿(和一堆代码)使用First Responder。

Before iOS 5, one would've needed to display another UIViewController using the First Responder via a Modal presentation (and a pile of code).

在Xcode中创建一个popover故事板模式(iOS 5+)使用 UIButton UIToolbarButton 并在按钮和<$之间创建一个Storyboard Segue c $ c> UIViewController 你要弹出

To create a popover in Xcode's Storyboard Mode (iOS 5+) use a UIButton or UIToolbarButton and create a Storyboard Segue between the button and the UIViewController that you want to pop-over.

在按钮和另一个按钮之间创建一个segue UIViewController 很简单。方法如下:

Creating a segue between a button and another UIViewController is simple. Here's how:


  1. 点击故事板中的按钮,然后控制 + 拖动从按钮到选择的 UIViewController 。您应该会看到一条从按钮延伸到鼠标尖端的浅蓝色线条。

  2. 将蓝线拖到选定的ViewController后会出现一个小黑色菜单。此菜单显示不同的segue选项。选择 Popover

  1. Click on the button in your storyboard and Control+Drag from the button to the UIViewController of choice. You should see a light blue line appear that extends from the button to the tip of your mouse.
  2. After dragging the blue line to the ViewController of choice a small black menu will appear. This menu displays the different segue options. Select Popover.

如果一切都正确完成,当选择按钮时,此segue应在Connections Inspector中可见:

If everything was done correctly, this segue should be visible in the Connections Inspector when the button is selected:

你创建的 UIViewController 也应该有一个更小的自定义尺寸比全屏。您可以通过选择View Controller并将其size属性设置为 freeform master (320 x)来设置自定义大小850)。

The UIViewController you create should also have a custom size that is smaller than the full screen. You can set a custom size by selecting the View Controller and setting its size property to freeform, or master (320 x 850).

这篇关于如何使用Xcode Storyboards创建Popovers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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