Xamarin iOS“演练-使用Elements API创建应用程序”崩溃

第一师

我试图遵循Xamarin的“演练-使用Elements API创建应用程序”,并且当我触摸“任务”时代码崩溃,该任务应该启动新屏幕以输入描述和日期选择器。单击NavigationItem.RightBarButtonItem时,将显示任务,但单击其中之一会导致应用程序在模拟器中关闭。

代码没有太多,而且我看不到哪里出了问题。

环境:
Visual Studio 2012> Xamarin构建主机> Mac OS 10.9.5

整个应用程序位于AppDelegate中:

using System;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit;
using MonoTouch.Dialog;

namespace ElementsApiWalkthrough
{
    public class Task
    {
        public Task(){}

        public string Name { get; set; }
        public string Description { get; set; }
        public DateTime DueDate { get; set; }
    }

    // The UIApplicationDelegate for the application. This class is responsible for launching the 
    // User Interface of the application, as well as listening (and optionally responding) to 
    // application events from iOS.
    [Register("AppDelegate")]
    public partial class AppDelegate : UIApplicationDelegate
    {
        // class-level declarations
        UIWindow _window;
        RootElement _rootElement;
        DialogViewController _rootVC;
        UINavigationController _nav;
        UIBarButtonItem _addButton;
        int n;


        //
        // This method is invoked when the application has loaded and is ready to run. In this 
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            _window = new UIWindow(UIScreen.MainScreen.Bounds);

            _rootElement = new RootElement("To Do List") { new Section() };

            // code to create screens with MT.D will go here …

            _rootVC = new DialogViewController(_rootElement);
            _nav = new UINavigationController(_rootVC);
            _window.RootViewController = _nav;
            _window.MakeKeyAndVisible();

            _addButton = new UIBarButtonItem(UIBarButtonSystemItem.Add);
            _rootVC.NavigationItem.RightBarButtonItem = _addButton;

            _addButton.Clicked += (sender, e) =>
            {

                ++n;

                var task = new Task { Name = "task " + n, DueDate = DateTime.Now };

                var taskElement = new RootElement(task.Name){
                    new Section () {
                            new EntryElement (task.Name, 
                                    "Enter task description", task.Description)
                    },
                    new Section () {
                            new DateElement ("Due Date", task.DueDate)
                    }
                };
                _rootElement[0].Add(taskElement);
            };


            return true;
        }

    }
}
第一师

我使用了新的iPhone项目类型。使用“经典”模板中的iPhone项目修复了该项目。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用xamarin创建的应用程序将是webapp或实际的本机ios应用程序

来自分类Dev

使用UnobservedTaskException停止HockeyApp使我的Xamarin iOS应用程序崩溃

来自分类Dev

Xamarin.Forms-iOS应用程序启动后崩溃

来自分类Dev

使用Xamarin iOS获取可用的应用程序内存

来自分类Dev

(Xamarin Forms) 启动时应用程序崩溃(使用应用程序属性登录/注销)

来自分类Dev

使用renderInContext:API渲染Webview图层时iOS应用程序崩溃

来自分类Dev

WinForms创建应用程序演练

来自分类Dev

Xamarin iOS WebException:HttpWebRequest完成后,应用程序崩溃

来自分类Dev

无法使用iOS默认相机应用程序捕获视频。Xamarin.iOS

来自分类Dev

Xamarin iOS绑定库视图控制器按钮单击会崩溃Xamarin表单应用程序

来自分类Dev

使用Xamarin开发iOS应用

来自分类Dev

使用UIwebview显示使用Google Maps API的网页时,iOS 7和应用程序崩溃

来自分类Dev

iOS应用程序(使用核心数据)在更新后崩溃,但仅应用程序商店版本崩溃

来自分类Dev

如何使用Xamarin for Visual Studio 2013为iOS应用程序构建IPA文件

来自分类Dev

如何仅使用Visual Studio编译Xamarin.iOS应用程序?

来自分类Dev

使用MVVMCross和Storyboard开发Xamarin.iOS应用程序

来自分类Dev

是否可以将NAudio.Lame与Xamarin(Android / iOS)应用程序一起使用?

来自分类Dev

为什么使用Xamarin Forms的iOS应用程序无法显示“真棒字体”?

来自分类Dev

如何使用 Xamarin.Forms 在 iOS 和 Android 应用程序中实现 Docusign?

来自分类Dev

没有为 Xamarin 中的 iOS 示例应用程序创建 assemblyinfo.cs 文件

来自分类Dev

Android中的async / await方法崩溃导致Web服务响应,但相同的代码在xamarin本机应用程序的Window Phone和iOS应用程序中成功运行

来自分类Dev

Xamarin.iOS应用程序在iOS 13上冻结

来自分类Dev

如何使用OxyPlot在Xamarin.Forms可移植应用程序中创建图表?

来自分类Dev

使用意图过滤器启动时Xamarin.Android mvvmcross应用程序崩溃

来自分类Dev

在 iOS 故事板中使用“Show”会导致 iOS 应用程序崩溃吗?

来自分类Dev

如何使用MSBuild构建Xamarin iOS应用?

来自分类Dev

使用Xamarin的iOS应用的安装日期

来自分类Dev

如何在Xamarin iOS中使用URL方案从我的应用程序中打开另一个应用程序

来自分类Dev

如何在Xamarin iOS中使用URL方案从我的应用程序中打开另一个应用程序

Related 相关文章

  1. 1

    使用xamarin创建的应用程序将是webapp或实际的本机ios应用程序

  2. 2

    使用UnobservedTaskException停止HockeyApp使我的Xamarin iOS应用程序崩溃

  3. 3

    Xamarin.Forms-iOS应用程序启动后崩溃

  4. 4

    使用Xamarin iOS获取可用的应用程序内存

  5. 5

    (Xamarin Forms) 启动时应用程序崩溃(使用应用程序属性登录/注销)

  6. 6

    使用renderInContext:API渲染Webview图层时iOS应用程序崩溃

  7. 7

    WinForms创建应用程序演练

  8. 8

    Xamarin iOS WebException:HttpWebRequest完成后,应用程序崩溃

  9. 9

    无法使用iOS默认相机应用程序捕获视频。Xamarin.iOS

  10. 10

    Xamarin iOS绑定库视图控制器按钮单击会崩溃Xamarin表单应用程序

  11. 11

    使用Xamarin开发iOS应用

  12. 12

    使用UIwebview显示使用Google Maps API的网页时,iOS 7和应用程序崩溃

  13. 13

    iOS应用程序(使用核心数据)在更新后崩溃,但仅应用程序商店版本崩溃

  14. 14

    如何使用Xamarin for Visual Studio 2013为iOS应用程序构建IPA文件

  15. 15

    如何仅使用Visual Studio编译Xamarin.iOS应用程序?

  16. 16

    使用MVVMCross和Storyboard开发Xamarin.iOS应用程序

  17. 17

    是否可以将NAudio.Lame与Xamarin(Android / iOS)应用程序一起使用?

  18. 18

    为什么使用Xamarin Forms的iOS应用程序无法显示“真棒字体”?

  19. 19

    如何使用 Xamarin.Forms 在 iOS 和 Android 应用程序中实现 Docusign?

  20. 20

    没有为 Xamarin 中的 iOS 示例应用程序创建 assemblyinfo.cs 文件

  21. 21

    Android中的async / await方法崩溃导致Web服务响应,但相同的代码在xamarin本机应用程序的Window Phone和iOS应用程序中成功运行

  22. 22

    Xamarin.iOS应用程序在iOS 13上冻结

  23. 23

    如何使用OxyPlot在Xamarin.Forms可移植应用程序中创建图表?

  24. 24

    使用意图过滤器启动时Xamarin.Android mvvmcross应用程序崩溃

  25. 25

    在 iOS 故事板中使用“Show”会导致 iOS 应用程序崩溃吗?

  26. 26

    如何使用MSBuild构建Xamarin iOS应用?

  27. 27

    使用Xamarin的iOS应用的安装日期

  28. 28

    如何在Xamarin iOS中使用URL方案从我的应用程序中打开另一个应用程序

  29. 29

    如何在Xamarin iOS中使用URL方案从我的应用程序中打开另一个应用程序

热门标签

归档