简体   繁体   English

如何通过情节提要(xib?)和以编程方式Xamarin.iOS制作Popup

[英]How to make Popup via storyboard(xib?) and programmatically Xamarin.iOS

For some reason i want to know how exactly i can implement Popup in Xamarin.iOS via storyboard and programmatically . 出于某种原因,我想知道如何通过情节提要和以编程方式在Xamarin.iOS中实现Popup


At current moment, i'm doing pretty simple workaround: 目前,我正在执行非常简单的解决方法:

Inside designer, i'm dropping additional view(as popup) and configure like that 在设计师内部,我要删除其他视图(作为弹出窗口)并像这样进行配置
MyPopupView.Hidden = true;

After some steps(nvm), i'm showing this popup via 经过一些步骤(NVM),我通过显示此弹出窗口

MyPopupView.Hidden = false;

And the result is : 结果是:
在此处输入图片说明

Yeah, that is bad and very poor approach, because what if need these 5 guys or more ? 是的,这是一种非常糟糕的方法,因为如果需要这5个人或更多的人怎么办?
I will not be able to design my ViewController , because it will be stuffed with these views. 我将无法设计ViewController ,因为它将填充这些视图。
Also, for some reason i want to show arrow (see img below) and shadow (outside of popup) for better usability. 另外,出于某种原因,我想显示箭头 (请参见下面的img)和阴影 (在弹出窗口之外)以提高可用性。


That what is exactly i want to do : 那正是我想做的:
在此处输入图片说明

or this one(but inside, i want to put for eg my xib or VC,where i can drop some other views, like .gif animation): 或这个(但在里面,我想放入例如xib或VC,我可以在其中放置其他一些视图,例如.gif动画):
在此处输入图片说明

or this one: 或这一个:
在此处输入图片说明

and finally, what i want(this one is amazing) : 最后,我想要什么(这个很棒):
在此处输入图片说明


Main idea to use storyboard(to make life easy with working on constraints and autolayout),but maybe it can be done programmatically the same. 使用情节提要的主要思想(使约束和自动布局的工作变得轻松),但也许可以在编程上相同。

I think that is possible to do that with UIAlertController , just needs to insert our View , but dunno is that right approach. 我认为使用UIAlertController可以做到这一点 ,只需插入我们的View ,但dunno是正确的方法。

Thanks for any advice. 感谢您的任何建议。

The last two images you posted can be accomplished using storyboards. 您发布的最后两个图像可以使用情节提要来完成。

Essentially what you to do is create a separate scene/view controller in your storyboard and set it's presentation property to "over current context" . 本质上,您要做的是在情节提要中创建一个单独的场景/视图控制器,并将其演示文稿属性设置为“在当前上下文中” 在此处输入图片说明 在此处输入图片说明

Alternatively you can set the segue to "Show modally" and the presentation property of the segue to "over current context" in Xcode 或者,您可以在Xcode中将segue设置为“以模态显示”,并将segue的presentation属性设置为“在当前上下文中”

在此处输入图片说明

(for some reason the "Over current context" option doesn't come up in Xamarin Studio (at least not in Xamarin Studio 6) and when you open it back up in XS it will display a "Error while creating this entry" message by the presentation property but it should still work). (由于某种原因,Xamarin Studio中没有出现“ Over current context”(在当前上下文中)选项(至少在Xamarin Studio 6中没有),并且当您在XS中将其打开时,它将显示一条“创建此条目时出错”消息,演示文稿属性,但它仍然可以正常工作)。

The next step is to set the root view to be transparent (background color = clear color ) and then have a child view with your content. 下一步是将根视图设置为透明(背景色= 透明色 ),然后将其内容与子视图一起使用。

在此处输入图片说明

If you want the semi-transparent overlay affect then what you can do is have two "sibling" child views one with your content (same as before) and a second view which is constrained to the edges of the root view and has it's alpha property set to something less then 1. 如果您希望半透明的叠加效果,那么您可以做的是拥有两个“兄弟”子视图,其中一个包含您的内容(与之前相同),另一个视图被约束到根视图的边缘并具有alpha属性设置为小于1。

在此处输入图片说明

在此处输入图片说明

And here's the result... 结果就是...

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xamarin.IOS导入现有的故事板 - Xamarin.IOS Import existing storyboard Xamarin.iOS 无法创建/打开故事板 - Xamarin.iOS cannot create/open storyboard xamarin.ios-以编程方式将视图添加到tableitem - xamarin.ios - adding views to tableitem programmatically 如何在Xamarin.ios本机应用程序的自定义控制器类中打开新的故事板? - How do I open a new storyboard from custom controller class in Xamarin.ios native app? 人类如何理解Xamarin.iOS Storyboard设计师的模糊布局约束部分? - How can a human understand the Xamarin.iOS Storyboard designer's ambiguous layout constraints section? 如何以编程方式添加UITabBarController(无xib文件或故事板) - How to add UITabBarController programmatically (no xib file or storyboard) 从Xamarin.iOS绑定库引用故事板 - Referencing Storyboard from Xamarin.iOS Binding Library Xamarin.ios 登录页面,无法更改故事板的第一页 - Xamarin.ios login page, cannot change the first page of storyboard Xamarin.iOS:没有情节提要时启动屏幕后黑屏 - Xamarin.iOS: Black screen after launch screen when no storyboard 找不到Xamarin.iOS / UIViewController上的MonoTouch故事板Segue - Xamarin.iOS / MonoTouch Storyboard Segue on UIViewController not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM