SideMenu for mvvmCross(SideMenu for mvvmCross)
为
Xamarin.iOS
应用程序实现侧面菜单,但在控制台中收到警告:mvx:警告:0.25没有发现侧面菜单。 要使用sidemenu使用'MvxPanelPresentationAttribute'类装饰viewcontroller类,并将面板设置为'Left'或'Right'。
脚步
1)为菜单创建基类(来自样本 )
public class BaseMenuViewController<T> : MvxViewController<T>, IMvxSidebarMenu where T : class, IMvxViewModel { public virtual UIImage MenuButtonImage => UIImage.FromBundle("burger"); public virtual bool AnimateMenu => true; public virtual float DarkOverlayAlpha => 0; public virtual bool HasDarkOverlay => false; public virtual bool HasShadowing => true; public virtual bool DisablePanGesture => false; public virtual bool ReopenOnRotate => true; private int MaxMenuWidth = 300; private int MinSpaceRightOfTheMenu = 55; public int MenuWidth => UserInterfaceIdiomIsPhone ? int.Parse(UIScreen.MainScreen.Bounds.Width.ToString()) - MinSpaceRightOfTheMenu : MaxMenuWidth; private bool UserInterfaceIdiomIsPhone { get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; } } public virtual void MenuWillOpen() { } public virtual void MenuDidOpen() { } public virtual void MenuWillClose() { } public virtual void MenuDidClose() { } }
2)实现VisibleView(第一个可见)
[MvxSidebarPresentation(MvxPanelEnum.Center, MvxPanelHintType.ResetRoot, true)] public partial class ContentViewController : MvxViewController<ContentViewModel> { public ContentViewController() : base("ContentViewController", null) { } public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.Purple; this.ViewModel.Show<MenuViewModel>(); } }
3)实现MenuElementViewController(SideMenu)
[Register("MenuViewController")] [MvxSidebarPresentation(MvxPanelEnum.Left, MvxPanelHintType.PushPanel, false)] public class MenuViewController : BaseMenuViewController<MenuViewModel> { public override void ViewDidLoad() { base.ViewDidLoad(); this.View.BackgroundColor = UIColor.Red; } }
4)在Setup中为SideMenu添加演示者
protected override IMvxIosViewPresenter CreatePresenter() { return new MvxSidebarPresenter((MvxApplicationDelegate)ApplicationDelegate, Window); }
预期的行为
应该从汉堡点按钮看点控制器
实际行为
来自point1的控制器变得可见,但是没有汉堡按钮,来自point2的控制器未初始化,在控制台中警告关于错过的类装饰,但是当你看到它们存在时(同样警告已弃用且需要更新 - 检查源代码 - 搜索完成正确类型,但警告有旧消息 )
组态
MvvmCross v 5.0.6
- MvvmCross
- MvvmCross.Core
- MvvmCross.Binding
- MvvmCross.iOS.Support
- MvvmCross.iOS.Support.XamarinSidebar
- MvvmCross.Platform
- SidebarNavigation
在查找错误时也看到了这篇文章 - 重新检查,看起来一切都很好,但不行。
警告日志:
mvx:诊断:0.21设置:次要结束
mvx:Diagnostic:0.21显示ViewModel ContentViewModel iOS导航:诊断:0.21导航请求
mvx:警告:0.23没有发现侧面菜单。 要使用sidemenu使用'MvxPanelPresentationAttribute'类装饰viewcontroller类,并将面板设置为'Left'或'Right'。
我还希望在调用
this.ViewModel.Show<MenuViewModel>();
时看到ViewDidload中的ViewDidload
在MenuViewController
停止this.ViewModel.Show<MenuViewModel>();
但它永远不会被触发,在此控制器创建的同一时刻模型中。有人可以建议做错了吗?
编辑
我能够使用侧边栏设置新的空项目,并且按预期工作。 但是相同的代码在我当前的项目中不起作用 - 我不知道为什么装饰属性没有按预期读取....
Tying to implement side menu for
Xamarin.iOS
app, but got warning in console:mvx:Warning: 0.25 No sidemenu found. To use a sidemenu decorate the viewcontroller class with the 'MvxPanelPresentationAttribute' class and set the panel to 'Left' or 'Right'.
Steps
1) Create base class for menu (from sample)
public class BaseMenuViewController<T> : MvxViewController<T>, IMvxSidebarMenu where T : class, IMvxViewModel { public virtual UIImage MenuButtonImage => UIImage.FromBundle("burger"); public virtual bool AnimateMenu => true; public virtual float DarkOverlayAlpha => 0; public virtual bool HasDarkOverlay => false; public virtual bool HasShadowing => true; public virtual bool DisablePanGesture => false; public virtual bool ReopenOnRotate => true; private int MaxMenuWidth = 300; private int MinSpaceRightOfTheMenu = 55; public int MenuWidth => UserInterfaceIdiomIsPhone ? int.Parse(UIScreen.MainScreen.Bounds.Width.ToString()) - MinSpaceRightOfTheMenu : MaxMenuWidth; private bool UserInterfaceIdiomIsPhone { get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; } } public virtual void MenuWillOpen() { } public virtual void MenuDidOpen() { } public virtual void MenuWillClose() { } public virtual void MenuDidClose() { } }
2) Implement VisibleView (First one that will be visible)
[MvxSidebarPresentation(MvxPanelEnum.Center, MvxPanelHintType.ResetRoot, true)] public partial class ContentViewController : MvxViewController<ContentViewModel> { public ContentViewController() : base("ContentViewController", null) { } public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.Purple; this.ViewModel.Show<MenuViewModel>(); } }
3) Implement MenuElementViewController (SideMenu)
[Register("MenuViewController")] [MvxSidebarPresentation(MvxPanelEnum.Left, MvxPanelHintType.PushPanel, false)] public class MenuViewController : BaseMenuViewController<MenuViewModel> { public override void ViewDidLoad() { base.ViewDidLoad(); this.View.BackgroundColor = UIColor.Red; } }
4) Add presenter for SideMenu in Setup
protected override IMvxIosViewPresenter CreatePresenter() { return new MvxSidebarPresenter((MvxApplicationDelegate)ApplicationDelegate, Window); }
Expected behavior
Should see controller from point 1 with burger button
Actual behavior
Controller from point1 become visible but without burger button, Controller from point2 not initialized, Warning in console about missed decoration for class, but as u see they are present (also warnings deprecated and need to be updated - check source code - searching done for correct type, but warning has old message )
Configuration
MvvmCross v 5.0.6
- MvvmCross
- MvvmCross.Core
- MvvmCross.Binding
- MvvmCross.iOS.Support
- MvvmCross.iOS.Support.XamarinSidebar
- MvvmCross.Platform
- SidebarNavigation
Also saw this post while looking for error - recheck and looks like everything is fine, but not work.
Warning log:
mvx:Diagnostic: 0.21 Setup: Secondary end
mvx:Diagnostic: 0.21 Showing ViewModel ContentViewModel iOSNavigation:Diagnostic: 0.21 Navigate requested
mvx:Warning: 0.23 No sidemenu found. To use a sidemenu decorate the viewcontroller class with the 'MvxPanelPresentationAttribute' class and set the panel to 'Left' or 'Right'.
I also expect to see breakPoint stop in
ViewDidload
forMenuViewController
when callthis.ViewModel.Show<MenuViewModel>();
but it's never triggered, in same moment model for this controller created.Can someone advice what was done incorrect?
EDIT
I was able to setup new empty project with sidebar and it's work as expected. But same code not work in my current projects - I don't know why decorated attributes are not read as expected....
原文:https://stackoverflow.com/questions/45082154
最满意答案
设置
display: inline-block
将允许您在宽度方向上实现所需的结果,但也意味着元素将以内联方式显示,即,如果它们适合,则彼此相邻。
您可以通过将元素包装在块样式容器中来避免这种情况。 虽然这听起来很不理想,但这是我头脑中第一个有效的想法。扩展您的进一步问题,您可以浮动这些元素,将它们包装在也显示为内联的容器中,然后使用RúnarBerg建议的空块来阻止它们。
HTML:
ACTUAL: <div></div> <div class="wrapper cf"> <div class="flex-text"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. </div> <div class="flex-text"> Lorem ipsum dolor sit amet. </div> <div class="flex-text"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </div> </div> <div></div> Further content
CSS:
.flex-text { min-width: 200px; max-width: 400px; display: inline-block; background: #def; float: left; clear: both; } /* this is just to show a 200px ruler for reference */ .flex-text:after { content: ""; display: block; width: 200px; border-top: 4px solid black; margin: 0 0 20px 0; } .wrapper { display: inline-block; background: lightblue; } .cf:before, .cf:after { content: " "; /* 1 */ display: table; /* 2 */ } .cf:after { clear: both; } .cf { *zoom: 1; }
Setting
display: inline-block
will allow you to achieve the desired result width-wise, but will also mean the elements will be displayed inline, that is, next to one another if they fit.
You can avoid this by wrapping your elements in block-style containers. While this sounds far from ideal it's the first idea off the top of my head that works.Expanding on your further question, you can float these elements, wrap them in a container that's also displayed inline and then block it using Rúnar Berg's suggestion of empty blocks.
See sample jsFiddle
Clearfix referenceHTML:
ACTUAL: <div></div> <div class="wrapper cf"> <div class="flex-text"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. </div> <div class="flex-text"> Lorem ipsum dolor sit amet. </div> <div class="flex-text"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </div> </div> <div></div> Further content
CSS:
.flex-text { min-width: 200px; max-width: 400px; display: inline-block; background: #def; float: left; clear: both; } /* this is just to show a 200px ruler for reference */ .flex-text:after { content: ""; display: block; width: 200px; border-top: 4px solid black; margin: 0 0 20px 0; } .wrapper { display: inline-block; background: lightblue; } .cf:before, .cf:after { content: " "; /* 1 */ display: table; /* 2 */ } .cf:after { clear: both; } .cf { *zoom: 1; }
相关问答
更多-
CSS容器最小高度100%(CSS container min-height 100%)[2022-04-12]
您可以使用calc propery动态计算高度。 只需将高度设置为100vh视口高度的100%,然后减去页脚高度(130px)和标题(130px)= 260px。 #content{ width: 100%; height: calc(100vh - 260px); min-height: 500px; } 为了防止它变得太小,你可以添加你喜欢的min-height属性。 演示 You can calculate the height dynamically with the calc ... -
由@PanyaKor提供 的基于表格的解决方案 。 Table-based solution by @PanyaKor.
-
表工作不同 有时是直观的。 解决方案是在表格单元格上使用width ,而不是max-width 。 虽然听起来好像在这种情况下,细胞不会缩小到给定的宽度以下,但实际上它们是不一样的。 对c没有限制,如果给表宽度为70px,则a,b和c的宽度分别为16,42和12像素。 桌面宽度为400像素,它们的行为就像您在上面的网格中所说的一样。 只有当您尝试给表格太小时(小于a.min + b.min + C的内容)将失败:表本身将比指定的更宽。 我做了一个新的小提琴 ,其中我删除了所有的边框和边框和边框间距,所以你可 ...
-
如何用这个类反转图像的行为? .post-body p img.thumb-small { min-width:0; } how can i reverse that behaviour for images with this class? .post-body p img.thumb-small { min-width:0; }
-
可能你必须定义device-width而不是简单的宽度。 像这样写: May be you have to define device-width instead of simple width. Write like thi ...
-
标题“如何继承最小宽度和最大宽度的宽度?”的简单答案 是: min-width: inherit; max-width: inherit; 由于中间还有一个辅助容器,所以你必须将其设置为该容器,并添加width: 100%; 对孩子来说,它似乎运作良好。 #main { position: relative; min-width: 200px; max-width: 300px; background: red; } #main_inner { min-width: ...
-
设置 display: inline-block 将允许您在宽度方向上实现所需的结果,但也意味着元素将以内联方式显示,即,如果它们适合,则彼此相邻。 您可以通过将元素包装在块样式容器中来避免这种情况。 虽然这听起来很不理想,但这是我头脑中第一个有效的想法。 扩展您的进一步问题,您可以浮动这些元素,将它们包装在也显示为内联的容器中,然后使用RúnarBerg建议的空块来阻止它们。 请参阅示例jsFiddle Clearfix参考 HTML: ACTUAL:我认为你需要媒体查询。 您可以设置不同视口的宽度。 #head { background-color:#00FF00; } body { text-align:center; } #container{ margin: 0 auto; width:100%; max-width:500px; text-align:center; } #left { background-color:#FF0000; float: l ...
CSS - 浮动到最大宽度(CSS - Float to max width)[2022-03-16]
当你希望它扩展以填充父级时,浮动某些东西没有多大意义。 只需从.info分区中删除float: left和width属性,以便它将展开以填充父级的宽度,然后添加margin-left: 100px将其从仍然浮动到的那个下方推出剩下。 It doesn't make much sense to float something when you want it to expand to fill the parent. Just remove the float: left and the width prop ...input { max-width: 300px; width:100%; line-height: 25px; } input { max-width: 300px; width:100%; line-height: 25px; }最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)