Mvvmcross - 容器UIViewController(Mvvmcross - Container UIViewController)
我正在尝试实现一个Custom UIViewController类,它将充当我的导航控制器,而不是使用默认的导航控制器。 下面是我的容器类:
enter code here
public partial class ContainerView:MvxViewController {static bool UserInterfaceIdiomIsPhone {get {return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; }}private UIViewController _currentView; protected ContainerViewModel ContainerModel { get { return base.ViewModel as ContainerViewModel; } } public ContainerView () : base (UserInterfaceIdiomIsPhone ? "ContainerView_iPhone" : "ContainerView_iPad", null) { } public override void ViewDidLoad () { base.ViewDidLoad (); var loginView = this.CreateViewControllerFor(ContainerModel.Login) as UIViewController; ShowViewController(loginView); // Perform any additional setup after loading the view, typically from a nib. } public ContainerView(UIViewController controller) : base(UserInterfaceIdiomIsPhone ? "ContainerView_iPhone" : "ContainerView_iPad", null) { ShowViewController(controller); } public void ShowViewController(UIViewController viewController) { if (_currentView !=null) { RemoveCurrentViewController(); } AddChildViewController(viewController); viewController.View.Frame = GetViewFrame(); containerView.AddSubview(viewController.View); _currentView = viewController; viewController.DidMoveToParentViewController(this); } public void RemoveCurrentViewController() { _currentView.WillMoveToParentViewController(null); _currentView.View.RemoveFromSuperview(); _currentView.RemoveFromParentViewController(); } public RectangleF GetViewFrame() { return containerView.Bounds; } }
我的第一次加载很好,因为登录视图被加载到containerView中,这是一个来自笔尖的插座。 问题是随后的请求我的插座是空的。 我可能做错了,但我试图在Presenter Show方法中设置viewcontroller,如下所示:
public class MyPresenter: MvxTouchViewPresenter { private static ContainerView _cv; public BlackhawkPresenter(MvxApplicationDelegate appDelegate, UIWindow window) : base(appDelegate, window) { _cv = new ContainerView(); window.RootViewController = _cv; } protected override UINavigationController CreateNavigationController(UIViewController viewController) { return new BlackhawkNavigationController(viewController); } public override void Show(Cirrious.MvvmCross.ViewModels.MvxViewModelRequest request) { var viewController = (UIViewController)Mvx.Resolve<IMvxTouchViewCreator>().CreateView(request); if(request.ViewModelType == typeof(ContainerViewModel)) base.Show(request); else _cv.ShowViewController(viewController); } }
对于show中的else语句,因为“ViewDidLoad”从不触发我的插座是null。 我不确定是否有任何阻止ShowViewModel将其显示在容器类容器View中的调用。
I am trying to implement a Custom UIViewController class that will act as my navigation controller rather than using the default navigation controller. Below is my container class I have:
enter code here
public partial class ContainerView : MvxViewController { static bool UserInterfaceIdiomIsPhone { get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; } }private UIViewController _currentView; protected ContainerViewModel ContainerModel { get { return base.ViewModel as ContainerViewModel; } } public ContainerView () : base (UserInterfaceIdiomIsPhone ? "ContainerView_iPhone" : "ContainerView_iPad", null) { } public override void ViewDidLoad () { base.ViewDidLoad (); var loginView = this.CreateViewControllerFor(ContainerModel.Login) as UIViewController; ShowViewController(loginView); // Perform any additional setup after loading the view, typically from a nib. } public ContainerView(UIViewController controller) : base(UserInterfaceIdiomIsPhone ? "ContainerView_iPhone" : "ContainerView_iPad", null) { ShowViewController(controller); } public void ShowViewController(UIViewController viewController) { if (_currentView !=null) { RemoveCurrentViewController(); } AddChildViewController(viewController); viewController.View.Frame = GetViewFrame(); containerView.AddSubview(viewController.View); _currentView = viewController; viewController.DidMoveToParentViewController(this); } public void RemoveCurrentViewController() { _currentView.WillMoveToParentViewController(null); _currentView.View.RemoveFromSuperview(); _currentView.RemoveFromParentViewController(); } public RectangleF GetViewFrame() { return containerView.Bounds; } }
My first load is fine as the login view is loaded into the containerView which is an outlet from the nib. The problem is on subsequent request my outlet is null. I may be doing this wrong but I am attempting to set the viewcontroller in the Presenter Show method as per below:
public class MyPresenter: MvxTouchViewPresenter { private static ContainerView _cv; public BlackhawkPresenter(MvxApplicationDelegate appDelegate, UIWindow window) : base(appDelegate, window) { _cv = new ContainerView(); window.RootViewController = _cv; } protected override UINavigationController CreateNavigationController(UIViewController viewController) { return new BlackhawkNavigationController(viewController); } public override void Show(Cirrious.MvvmCross.ViewModels.MvxViewModelRequest request) { var viewController = (UIViewController)Mvx.Resolve<IMvxTouchViewCreator>().CreateView(request); if(request.ViewModelType == typeof(ContainerViewModel)) base.Show(request); else _cv.ShowViewController(viewController); } }
for the else statement in the show as the "ViewDidLoad" never fires my outlet is null. I am not sure of any othe rway to intercept the call for ShowViewModel to display it in container View in my container class.
原文:https://stackoverflow.com/questions/21806826
最满意答案
你有一个自引用表。 这并不全是坏事。 你所要做的就是创建一个像这样的查询。
SELECT * FROM content where subcontentID = contentID AND contentID = @contentID
结果将是具有指定contentID的所有内容记录
如果您也需要查看所有数据,则有序的结果集可能会更好。
SELECT * FROM content where subcontentID = contentID ORDER BY subcontentID,contentID
这将为您提供所有内容记录,将所有子内容记录保存在一起。
这完全没有问题,它可以避免使用相同的模式创建重复的表。
You have a self referencing table. This isn't all bad. All you have to do is create a query like this.
SELECT * FROM content where subcontentID = contentID AND contentID = @contentID
The results will be all the content records that have the specified contentID
An ordered result set might be nice if you need to see all the data too.
SELECT * FROM content where subcontentID = contentID ORDER BY subcontentID,contentID
This will give you all the content records keeping all the subcontent records together in order.
This is not bad at all it saves from creating a duplicate table with the same schema.
相关问答
更多-
preg_match("/\[(.+)\]/",$string,$matches); echo $matches[1]; preg_match("/\[(.+)\]/",$string,$matches); echo $matches[1];
-
经过几个小时的解析自己很多网站后,我找到了一些东西: JE.ValById("#code") - 返回textarea或任何输入的值 JsCmds.SetValById("#code", "test value") - 将vlaue设置为找到的元素 After some hours of parsing myself a lot of sites, i found something : JE.ValById("#code") - returns value of textarea or any input ...
-
从子内容检索内容(Retrieving Content from a Sub Content)[2022-05-13]
你有一个自引用表。 这并不全是坏事。 你所要做的就是创建一个像这样的查询。 SELECT * FROM content where subcontentID = contentID AND contentID = @contentID 结果将是具有指定contentID的所有内容记录 如果您也需要查看所有数据,则有序的结果集可能会更好。 SELECT * FROM content where subcontentID = contentID ORDER BY subcontentID,contentID ... -
当您需要使用不间断的空间时,就是这种情况 。 如果是HTML内容,那么您可以使用 World 。 然而,你需要使用unicode编码形式的U+00A0 :before ,它看起来像这样: p#content { border: 1px solid black; padding: 5px; width: 65px; } a.textLink:before { content: ...
-
用户通过单击列对内容进行排序后检索JTable行内容(Retrieving JTable line content after user sorted content by clicking on column)[2022-05-31]
没有任何代码,很难确定你的问题是什么。 但是,听起来你混淆了视图和模型之间的行索引。 当您有行号时,您必须非常清楚您所指的坐标系统(视图或模型)。 有关convertRowIndexToModel和convertRowIndexToView方法,请参阅JTable API 。 你可能需要这样的东西: JTable table = ...; TableModel model = ...; int viewRow = table.getSelectedRow(); int modelRow = table.c ... -
我还就此问题向供应商提出了支持电话。 事实证明,Valence API版本<= 1.4中的错误是由包含主题文件的模块触发的,该主题文件以点/句点结束(因此,一旦给定扩展名,其形式为some_file..ext )。 解决方案:升级到修复错误的Valence 1.6,或重命名受影响的文件。 I also raised a support call with the vendor for this issue. It turns out to be a bug in Valence API versions < ...
-
由于安全性限制,您无法跨域(/ ports / protocols)直接与正文中的其他元素通信。 您不仅无法访问目标文档源,也无法访问对象和事件。 您可以做的是使用框架通过代理跨域发送消息。 这个答案谈到了这一点。 You can not directly communicate with other elements in the body across domains (/ports/protocols) due to security constraints. Not only can't you a ...
-
您需要执行http get请求 import urllib2 link = "http://whatever.com/your-file.js" urllib2.urlopen(link).read() php代码正在使用curl,它比它看起来做的更多 You need to do a http get request import urllib2 link = "http://whatever.com/your-file.js" urllib2.urlopen(link).read() The php ...
-
检索函数的内容(retrieve content of a function)[2022-01-19]
您可以使用表集合表达式 : table_collection_expression允许您通知Oracle,应将collection_expression的值视为表,以便进行查询和DML操作。 collection_expression可以是子查询,列,函数或集合构造函数。 无论其形式如何,它都必须返回一个集合值 - 即类型为嵌套表或varray的值。 提取集合元素的过程称为集合取消。 因此,在您的情况下,当您的函数返回嵌套表类型时,您可以执行以下操作: select * from table(exportF ... -
存储到文件并使用Python检索文件的内容(storing to a file and retrieving the content of a file with Python)[2023-06-07]
saveData不返回任何内容,不返回文件名 filename = saveData(members) loadData不返回文件名,它返回成员。 filename = loadData() 我建议研究全局变量如何在Python中工作。 您只需要一个members实例。 如果您正在寻找更好的方法来执行CRUD操作,请使用Python的sqlite模块 顺便说一句,Pycharm有一个有用的调试器。 saveData returns nothing, not the filename filename = ...