草庐IT

c# - Xamarin.IOS : UITableViewSource crashes on device

coder 2023-07-29 原文

我有一个非常简单的应用程序,它只包含 UITableView 及其 UITableViewSource..

在不链接到 UITableViewSource 的情况下使用 UITableView 时(该应用在模拟器和设备中运行)

但是当我将 UITableView 链接到 UITableViewSource 时(该应用在模拟器中运行在设备上崩溃)

(设备是 iPad 运行 IOS 9.2.1 )

它给了我这个长错误:

2016-02-08 05:16:02.913 secondApp[4487:1711787] critical: Stacktrace:

2016-02-08 05:16:02.913 secondApp[4487:1711787] critical:   at <unknown> <0xffffffff>
2016-02-08 05:16:02.915 secondApp[4487:1711787] critical:   at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0xffffffff>
2016-02-08 05:16:02.915 secondApp[4487:1711787] critical:   at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/UIKit/UIApplication.cs:77
2016-02-08 05:16:02.916 secondApp[4487:1711787] critical:   at UIKit.UIApplication.Main (string[],string,string) [0x0001c] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/UIKit/UIApplication.cs:60
2016-02-08 05:16:02.916 secondApp[4487:1711787] critical:   at secondApp.Application.Main (string[]) [0x00008] in /Users/Mujtaba/Desktop/XamarinProjects/secondApp/secondApp/Main.cs:12
2016-02-08 05:16:02.917 secondApp[4487:1711787] critical:   at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
2016-02-08 05:16:02.917 secondApp[4487:1711787] critical: 
Native stacktrace:

2016-02-08 05:16:02.982 secondApp[4487:1711787] critical:   0   secondApp                           0x0027ffb5 mono_handle_native_sigsegv + 240
2016-02-08 05:16:02.982 secondApp[4487:1711787] critical:   1   secondApp                           0x00286243 mono_sigsegv_signal_handler + 226
2016-02-08 05:16:02.983 secondApp[4487:1711787] critical:   2   libsystem_platform.dylib            0x20f3385f _sigtramp + 42
2016-02-08 05:16:02.983 secondApp[4487:1711787] critical:   3   secondApp                           0x00323310 xamarin_stret_trampoline + 96
2016-02-08 05:16:02.984 secondApp[4487:1711787] critical:   4   UIKit                               0x25479d29 <redacted> + 2976
2016-02-08 05:16:02.984 secondApp[4487:1711787] critical:   5   UIKit                               0x2547907b <redacted> + 378
2016-02-08 05:16:02.984 secondApp[4487:1711787] critical:   6   UIKit                               0x25478e2d <redacted> + 56
2016-02-08 05:16:02.985 secondApp[4487:1711787] critical:   7   UIKit                               0x25478c33 <redacted> + 314
2016-02-08 05:16:02.985 secondApp[4487:1711787] critical:   8   UIKit                               0x256d4293 <redacted> + 42
2016-02-08 05:16:02.985 secondApp[4487:1711787] critical:   9   UIKit                               0x2547f295 <redacted> + 128
2016-02-08 05:16:02.986 secondApp[4487:1711787] critical:   10  UIKit                               0x25391369 <redacted> + 1480
2016-02-08 05:16:02.986 secondApp[4487:1711787] critical:   11  UIKit                               0x253b5fd5 <redacted> + 68
2016-02-08 05:16:02.986 secondApp[4487:1711787] critical:   12  UIKit                               0x253910ab <redacted> + 778
2016-02-08 05:16:02.987 secondApp[4487:1711787] critical:   13  UIKit                               0x253907ed <redacted> + 124
2016-02-08 05:16:02.987 secondApp[4487:1711787] critical:   14  UIKit                               0x2539069b <redacted> + 426
2016-02-08 05:16:02.987 secondApp[4487:1711787] critical:   15  UIKit                               0x2539d713 <redacted> + 1658
2016-02-08 05:16:02.987 secondApp[4487:1711787] critical:   16  UIKit                               0x2539d08f <redacted> + 30
2016-02-08 05:16:02.988 secondApp[4487:1711787] critical:   17  UIKit                               0x2539c87d <redacted> + 496
2016-02-08 05:16:02.988 secondApp[4487:1711787] critical:   18  UIKit                               0x25399bf3 <redacted> + 278
2016-02-08 05:16:02.988 secondApp[4487:1711787] critical:   19  UIKit                               0x2540e915 <redacted> + 48
2016-02-08 05:16:02.989 secondApp[4487:1711787] critical:   20  UIKit                               0x2563311d <redacted> + 3320
2016-02-08 05:16:02.989 secondApp[4487:1711787] critical:   21  UIKit                               0x25636f0f <redacted> + 1570
2016-02-08 05:16:02.989 secondApp[4487:1711787] critical:   22  UIKit                               0x2564ac15 <redacted> + 36
2016-02-08 05:16:02.989 secondApp[4487:1711787] critical:   23  UIKit                               0x256343f7 <redacted> + 134
2016-02-08 05:16:02.990 secondApp[4487:1711787] critical:   24  FrontBoardServices                  0x2250fc75 <redacted> + 232
2016-02-08 05:16:02.990 secondApp[4487:1711787] critical:   25  FrontBoardServices                  0x2250ff61 <redacted> + 44
2016-02-08 05:16:02.990 secondApp[4487:1711787] critical:   26  CoreFoundation                      0x211c1257 <redacted> + 14
2016-02-08 05:16:02.990 secondApp[4487:1711787] critical:   27  CoreFoundation                      0x211c0e47 <redacted> + 454
2016-02-08 05:16:02.990 secondApp[4487:1711787] critical:   28  CoreFoundation                      0x211bf1af <redacted> + 806
2016-02-08 05:16:02.991 secondApp[4487:1711787] critical:   29  CoreFoundation                      0x21111bb9 CFRunLoopRunSpecific + 516
2016-02-08 05:16:02.991 secondApp[4487:1711787] critical:   30  CoreFoundation                      0x211119ad CFRunLoopRunInMode + 108
2016-02-08 05:16:02.991 secondApp[4487:1711787] critical:   31  UIKit                               0x25403a17 <redacted> + 526
2016-02-08 05:16:02.991 secondApp[4487:1711787] critical:   32  UIKit                               0x253fdfb5 UIApplicationMain + 144
2016-02-08 05:16:02.992 secondApp[4487:1711787] critical:   33  secondApp                           0x000f4044 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 272
2016-02-08 05:16:02.992 secondApp[4487:1711787] critical:   34  secondApp                           0x000bd130 UIKit_UIApplication_Main_string___intptr_intptr + 52
2016-02-08 05:16:02.992 secondApp[4487:1711787] critical:   35  secondApp                           0x000bd0f0 UIKit_UIApplication_Main_string___string_string + 204
2016-02-08 05:16:02.992 secondApp[4487:1711787] critical:   36  secondApp                           0x000b714c secondApp_Application_Main_string__ + 188
2016-02-08 05:16:02.992 secondApp[4487:1711787] critical:   37  secondApp                           0x002101b4 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 256
2016-02-08 05:16:02.993 secondApp[4487:1711787] critical:   38  secondApp                           0x0028888f mono_jit_runtime_invoke + 1150
2016-02-08 05:16:02.993 secondApp[4487:1711787] critical:   39  secondApp                           0x002c71f5 mono_runtime_invoke + 88
2016-02-08 05:16:02.993 secondApp[4487:1711787] critical:   40  secondApp                           0x002ca64b mono_runtime_exec_main + 282
2016-02-08 05:16:02.993 secondApp[4487:1711787] critical:   41  secondApp                           0x00332fa4 xamarin_main + 2072
2016-02-08 05:16:02.994 secondApp[4487:1711787] critical:   42  secondApp                           0x0025aac5 main + 112
2016-02-08 05:16:02.994 secondApp[4487:1711787] critical:   43  libdyld.dylib                       0x20dc4873 <redacted> + 2
2016-02-08 05:16:02.994 secondApp[4487:1711787] critical: 
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

我所有的项目只包含 2 个 View :)

ViewController.cs :

using System;
using UIKit;

namespace secondApp
{
    public partial class ViewController : UIViewController
    {
        public ViewController (IntPtr handle) : base (handle)
        {
        }

        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();

            string[] list = new string[]{"Red", "Blue", "Brown", "Green" };

            UITableView table = new UITableView {
                Frame = new CoreGraphics.CGRect (0, 0, View.Bounds.Width, View.Bounds.Height),

                Source = new myTableSource(list)   // the problem happens when I add this line
            };

            View.AddSubview (table);

        }

        public override void DidReceiveMemoryWarning ()
        {
            base.DidReceiveMemoryWarning ();
        }
    }
}

myTableSource.cs:

using System;
using UIKit;

namespace secondApp
{
    public class myTableSource : UITableViewSource
    {
        string[] TableItems;
        string CellIdentifier = "TableCell";

        public myTableSource (string[] items)
        {
            TableItems = items;
        }

        public override nint RowsInSection (UITableView tableview, nint section)
        {
            return TableItems.Length;
        }

        public override UITableViewCell GetCell (UITableView tableView, Foundation.NSIndexPath indexPath)
        {
            UITableViewCell cell = tableView.DequeueReusableCell (CellIdentifier);
            string item = TableItems[indexPath.Row];

            if (cell == null){
                cell = new UITableViewCell (UITableViewCellStyle.Default, CellIdentifier);
            }

            cell.TextLabel.Text = item;

            return cell;
        }
    }
}

希望这个错误有一个简单的解决方案,因为我还处于学习Xamarin的第一步

提前致谢..

最佳答案

将近一周后,问题自行解决,相同的解决方案相同的设备上完美运行......

我只做了 Build -> Clean All .. 也许它解决了问题,或者也许只等了一周就解决了问题

关于c# - Xamarin.IOS : UITableViewSource crashes on device,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35261617/

有关c# - Xamarin.IOS : UITableViewSource crashes on device的更多相关文章

  1. c# - 如何在 ruby​​ 中调用 C# dll? - 2

    如何在ruby​​中调用C#dll? 最佳答案 我能想到几种可能性:为您的DLL编写(或找人编写)一个COM包装器,如果它还没有,则使用Ruby的WIN32OLE库来调用它;看看RubyCLR,其中一位作者是JohnLam,他继续在Microsoft从事IronRuby方面的工作。(估计不会再维护了,可能不支持.Net2.0以上的版本);正如其他地方已经提到的,看看使用IronRuby,如果这是您的技术选择。有一个主题是here.请注意,最后一篇文章实际上来自JohnLam(看起来像是2009年3月),他似乎很自在地断言RubyCL

  2. C# 到 Ruby sha1 base64 编码 - 2

    我正在尝试在Ruby中复制Convert.ToBase64String()行为。这是我的C#代码:varsha1=newSHA1CryptoServiceProvider();varpasswordBytes=Encoding.UTF8.GetBytes("password");varpasswordHash=sha1.ComputeHash(passwordBytes);returnConvert.ToBase64String(passwordHash);//returns"W6ph5Mm5Pz8GgiULbPgzG37mj9g="当我在Ruby中尝试同样的事情时,我得到了相同sha

  3. 基于C#实现简易绘图工具【100010177】 - 2

    C#实现简易绘图工具一.引言实验目的:通过制作窗体应用程序(C#画图软件),熟悉基本的窗体设计过程以及控件设计,事件处理等,熟悉使用C#的winform窗体进行绘图的基本步骤,对于面向对象编程有更加深刻的体会.Tutorial任务设计一个具有基本功能的画图软件**·包括简单的新建文件,保存,重新绘图等功能**·实现一些基本图形的绘制,包括铅笔和基本形状等,学习橡皮工具的创建**·设计一个合理舒适的UI界面**注明:你可能需要先了解一些关于winform窗体应用程序绘图的基本知识,以及关于GDI+类和结构的知识二.实验环境Windows系统下的visualstudio2017C#窗体应用程序三.

  4. c# - C# 中的 Flatten Ruby 方法 - 2

    我如何做Ruby方法"Flatten"RubyMethod在C#中。此方法将锯齿状数组展平为一维数组。例如:s=[1,2,3]#=>[1,2,3]t=[4,5,6,[7,8]]#=>[4,5,6,[7,8]]a=[s,t,9,10]#=>[[1,2,3],[4,5,6,[7,8]],9,10]a.flatten#=>[1,2,3,4,5,6,7,8,9,10 最佳答案 递归解决方案:IEnumerableFlatten(IEnumerablearray){foreach(variteminarray){if(itemisIEnume

  5. ruby - 可以像在 C# 中使用#region 一样在 Ruby 中使用 begin/end 吗? - 2

    我最近从C#转向了Ruby,我发现自己无法制作可折叠的标记代码区域。我只是想到做这种事情应该没问题:classExamplebegin#agroupofmethodsdefmethod1..enddefmethod2..endenddefmethod3..endend...但是这样做真的可以吗?method1和method2最终与method3是同一种东西吗?还是有一些我还没有见过的用于执行此操作的Ruby惯用语? 最佳答案 正如其他人所说,这不会改变方法定义。但是,如果要标记方法组,为什么不使用Ruby语义来标记它们呢?您可以使用

  6. c# - Ruby 等效于 C# Linq 聚合方法 - 2

    什么是Linq聚合方法的ruby​​等价物。它的工作原理是这样的varfactorial=new[]{1,2,3,4,5}.Aggregate((acc,i)=>acc*i);每次将数组序列中的值传递给lambda时,变量acc都会累积。 最佳答案 这在数学以及几乎所有编程语言中通常称为折叠。它是更普遍的变形概念的一个实例。Ruby从Smalltalk中继承了这个特性的名称,它被称为inject:into:(像aCollectioninject:aStartValueinto:aBlock一样使用。)所以,在Ruby中,它称为inj

  7. c# - 先学什么? - 2

    关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭8年前。Improvethisquestion几年前我去学校学习编程,毕业后我找到了一份系统管理方面的工作,这就是我职业生涯的方向。我想重新开始某种开发,并且一直在“玩”C#和ASP.NET,但我已经听到很多关于其他"new"语言的讨论(新的意思是它们是新的)我)喜欢Ruby和F#。我想我想知道我是否在浪费时间学习主要的MS语言,而不是成为一名通才。很长一段时间没有离开开发社区(如果我曾经离开过的话)让我在潮流中挣扎,我不想落在时代的

  8. c# - 在 C# 中重现 Ruby OpenSSL private_encrypt 输出 - 2

    我有一个简单的Ruby脚本,我用它在某些HTTPheader上执行private_encrypt以签署要发送到ruby​​RESTAPI的Web请求,该API会根据Base64编码字符串测试Base64编码字符串生成而不是解码Base64和解密数据然后测试原始字符串。我使用的脚本是require"openssl"require"base64"path_to_cert=ARGV[0].dupplain_text=Base64.decode64(ARGV[1].dup)private_key=OpenSSL::PKey::RSA.new(File.read(path_to_cert))pu

  9. C# 的 LINQ 用于在 ruby​​ 中等效的集合操作 - 2

    我是ruby​​开发的新手,我目前正在使用rails2.3.11在ruby​​1.8.7中开发一个项目,我想知道这种语言是否有与C#的linq等效的集合操作,例如where子句。谢谢。 最佳答案 Ruby中Linq的where等价于find_all检查documentationfortheEnumerableModule用于其他功能。 关于C#的LINQ用于在ruby​​中等效的集合操作,我们在StackOverflow上找到一个类似的问题: https://

  10. c# - 将 Ruby 的时间转换为 C# - 2

    我正在尝试转换Ruby的time到C#,但我现在卡住了。这是我的尝试:publicstaticclassExtensions{publicstaticvoidTimes(thisInt32times,WhatGoesHere?){for(inti=0;i我是C#的新手,也许这个应该很简单,而且我知道我想使用Extensionmethods。但由于函数在C#中不是“第一类”,我现在被卡住了。那么,我应该为WhatGoesHere使用什么参数类型? 最佳答案 您可以使用Action输入:publicstaticclassExtensio

随机推荐