你做:
1)从那里创建一个DialogVIEwController并树上每个视图/ RootElement,
2)为每个视图创建一个DialogVIEwController,并使用UINavigationController并根据需要推送它
根据你的答案,更好的反应是怎样的?我已经构建了示例任务应用程序,所以我了解向表中添加元素,单击它以转到“下一个”视图进行编辑,但是如何点击进行非编辑?如何点击一个按钮,如果答案是1,请去下一个视图?
修订:
可能没有一个正确的答案,但是我想出来的似乎对我们有用.来自上面的第2号是所选择的,下面是当前存在的代码示例.我们所做的是在AppDelegate中创建一个导航控制器,并在整个应用程序中访问它,如下所示:
public partial class AppDelegate : UIApplicationDelegate{ public UIWindow window { get; private set; } //< There's a Window property/fIEld which we chose not to bother with public static AppDelegate Current { get; private set; } public UINavigationController NavController { get; private set; } public overrIDe bool FinishedLaunching (UIApplication app,NSDictionary options) { Current = this; window = new UIWindow (UIScreen.MainScreen.Bounds); NavController = new UINavigationController(); // See About Controller below DialogVIEwController about = new AboutController(); NavController.PushVIEwController(about,true); window.RootVIEwController = NavController; window.MakeKeyAndVisible (); return true; }}
那么每个Dialog都有一个这样的结构:
public class AboutController : DialogVIEwController{ public delegate voID D(AboutController dvc); public event D VIEwLoaded = delegate { }; static About about; public AboutController() : base(about = new About()) { autorotate = true; about.SetDialogVIEwController(this); } public overrIDe voID LoadVIEw() { base.LoadVIEw(); VIEwLoaded(this); }}public class About : RootElement{ static AboutModel about = AboutVM.About; public About() : base(about.Title) { string[] message = about.Text.Split(...); Add(new Section(){ new AboutMessage(message[0]),new About_Image(about),new AboutMessage(message[1]),}); } internal voID SetDialogVIEwController(AboutController dvc) { var next = new UIbarbuttonItem(UIbarbuttonSystemItem.Play); dvc.NavigationItem.RightbarbuttonItem = next; dvc.VIEwLoaded += new AboutController.D(dvc_VIEwLoaded); next.Clicked += new System.EventHandler(next_Clicked); } voID next_Clicked(object sender,System.EventArgs e) { // Load next controller AppDelegate.Current.NavController.PushVIEwController(new IssuesController(),true); } voID dvc_VIEwLoaded(AboutController dvc) { // Swipe location: https://gist.github.com/2884348 dvc.VIEw.Swipe(UISwipeGestureRecognizerDirection.left).Event += delegate { next_Clicked(null,null); }; }}
根据需要创建一个子类的元素:
public class About_Image : Element,IElementSizing{ static Nsstring skey = new Nsstring("About_Image"); AboutModel about; UIImage image; public About_Image(AboutModel about) : base(string.Empty) { this.about = about; fileInfo imagefile = App.libraryfile(about.Image ?? "filler.png"); if (imagefile.Exists) { float size = 240; image = UIImage.Fromfile(imagefile.Fullname); var resizer = new ImageResizer(image); resizer.Resize(size,size); image = resizer.ModifIEdImage; } } public overrIDe UItableVIEwCell GetCell(UItableVIEw tv) { var cell = tv.DequeueReusableCell(skey); if (cell == null) { cell = new UItableVIEwCell(UItableVIEwCellStyle.Default,skey) { SelectionStyle = UItableVIEwCellSelectionStyle.None,Accessory = UItableVIEwCellAccessory.None,}; } if (null != image) { cell.ImageVIEw.ContentMode = UIVIEwContentMode.Center; cell.ImageVIEw.Image = image; } return cell; } public float GetHeight(UItableVIEw tableVIEw,NSIndexPath indexPath) { float height = 100; if (null != image) height = image.Size.Height; return height; } public overrIDe voID Selected(DialogVIEwController dvc,UItableVIEw tableVIEw,NSIndexPath indexPath) { //base.Selected(dvc,tableVIEw,path); tableVIEw.deselectRow(indexPath,true); }}
@miquel
目前的工作流概念是一个应用程序,它以Default.png的jpg开始,该JPG可以逐渐进入第一个视图,并具有可以移动到主应用程序的流控制按钮.这个观点,我曾经在M.T.D. (Monotouch.Dialog),它是具有图像的文本行的表.当每一行被单击时,它将移动到具有行/文本的另一个视图.
该应用程序还支持应用内购买,所以如果客户希望购买更多的产品,然后切换到另一个视图来处理购买.这部分是切换到M.T.D.的主要原因,正如我认为M.T.D.将是完美的.
最后,会有一个设置视图来重新启用购买等.
PS如何知道应用程序何时未被最小化?我们想再次显示褪色.
解决方法 我一直在问自己同样的问题.我使用了 Funq依赖注入框架,并为每个视图创建一个新的DialogVIEwController.这是我以前使用过的开发ASP.NET MVC应用程序的方法,这意味着我可以保持控制器逻辑很好地分离.我为每个视图子类DialogVIEwController,允许我将控制器所需的任何应用程序数据传递给控制器.我不知道这是否是推荐的方法,但到目前为止,它正在为我工作.我也看过TweetStation应用程序,我发现它是一个有用的参考,但相关的文档具体说,它并不是试图成为一个如何构造Monotouch应用程序的例子.
总结以上是内存溢出为你收集整理的uinavigationcontroller – 构造MonoTouch.Dialog应用程序全部内容,希望文章能够帮你解决uinavigationcontroller – 构造MonoTouch.Dialog应用程序所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)