Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# monotouch对象未设置为实例。tableview数据未填充文本视图_C#_Xamarin.ios_Nullreferenceexception - Fatal编程技术网

C# monotouch对象未设置为实例。tableview数据未填充文本视图

C# monotouch对象未设置为实例。tableview数据未填充文本视图,c#,xamarin.ios,nullreferenceexception,C#,Xamarin.ios,Nullreferenceexception,我有一个保存个人信息的tableview。这些信息来自TextView,并放入一个数组中,最后以txt文件的形式存储在磁盘上。 当一个人选择一个条目来更新我读取的文件中的个人信息时,将数据放回数组中,希望用原始数据填充文本视图 这是我的问题陈述。我想用文件中的数据填充TextView 我可以选择此人,但接收System.NullReferenceException:对象引用未设置为对象的实例 我正在使用来自Xamian和其他人的示例填充tableview。 我的程序由公共部分类RegintScr

我有一个保存个人信息的tableview。这些信息来自TextView,并放入一个数组中,最后以txt文件的形式存储在磁盘上。 当一个人选择一个条目来更新我读取的文件中的个人信息时,将数据放回数组中,希望用原始数据填充文本视图 这是我的问题陈述。我想用文件中的数据填充TextView

我可以选择此人,但接收System.NullReferenceException:对象引用未设置为对象的实例

我正在使用来自Xamian和其他人的示例填充tableview。 我的程序由公共部分类RegintScreen:UIViewController组成,其中包含TextView和其他控件。我使用xib创建物理接口。 我的公共类RegintTableSource:UITableViewSource具有常规方法RowsinSection和RowsSelected。 我使用RowSelected作为方法来了解需要更新哪些人员数据。当我选择一个人时,选中的行将激发并开始处理。我传回所选人员索引号,然后读取文件并放入数组中。当我尝试使用数组数据填充textview时,我得到了空引用异常

下面是获取person selected索引并传递回另一个类的两种方法

    public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
    {
        //myPersonSelected = new RegistrantScreen (facility);
        AnIndexSelected = true;
        //need to read the fac file so we know if on site or off site for populating the boxes.
        int person = indexPath.Row  ;
        //new UIAlertView("Row Selected", tableItems[indexPath.Row], null, "OK", null).Show(); 
        tableView.DeselectRow (indexPath, true); 
        upDateOne (person);//jump over and get the file and fill an array for the person selected.
    }//end of public override void RowSelected (UITableView tableView, NSIndexPath indexPath)



    public void upDateOne(int rowPerson)//rowPerson is the selected index of registrants.
    {
        string facilityFolder =Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
        facilityFolder = System.IO.Path.Combine (facilityFolder , "Facilities");
        facilityFolder = System.IO.Path.Combine (facilityFolder, "tmpFacility");

        string facility = File.ReadAllText (facilityFolder);//has the name of the facility to open
        string tmpRegistrants = facility.Replace ("fac", "par");//this holds the participants information.

        facilityFolder =Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
        facilityFolder = System.IO.Path.Combine (facilityFolder , "Facilities");
        tmpRegistrants = facility.Replace ("fac", "par");//this holds the participants information.
        facilityFolder = System.IO.Path.Combine (facilityFolder , tmpRegistrants );//should be reading the par file now.
        registrants = System.IO.File.ReadAllLines (facilityFolder);//this is the array for the selected participant.
        //string [] personToUpdate = registrants[rowPerson];
        //fillBoxes (Convert.ToString ( registrants[rowPerson]) );
        //need to populate the text boxes next.
        //need to check for commas again.
        RegistrantScreen myPersonSelected;
        myPersonSelected =  new RegistrantScreen (facility );


        //myPersonSelected .tableIndexChanged (rowPerson);
         myPersonSelected.updateForOne(rowPerson );
        ;
    }//end of public void upDateOne(int rowPerson)
这里是我传递数据的地方

    public void updateForOne(int person)//fill the textboxes for one person.
    {
        facilityFolder=Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
        facilityFolder= System.IO.Path.Combine (facilityFolder, "Facilities");
        facilityName= System.IO.Path.Combine (facilityFolder, Title);
        facilityLines = System.IO.File.ReadAllLines (facilityName);//get the facility info to use for decision making.
        string participantFile = facilityName.Replace ("fac", "par");
        string [] participantList = System.IO.File.ReadAllLines (participantFile);//get all the participants

        char [] deLimChars = { ',' };
        string[] words = participantList[person].Split( deLimChars );

        RegistrantScreen myTest = new RegistrantScreen (Title );

        tbXXXXapproval.Text = words[0];  ****Null reference exception here.****
我认为我的对象被垃圾收集,但还没有找到使我的textview和其他控件不为null的进程。
非常感谢您提供的任何帮助或指针。

您是否验证了
words
是否为null或空?words确实包含用于填充的数组值。文本视图本身为空。我认为这是错误,但尚未找到要更正的混合。您可以添加用于实例化TextView的代码吗?//加载视图后,通常从nib执行任何其他设置。ParticipantTable=新UITableView(新矩形F(134400518575));ParticipantTable.AutoresizingMask=ui视图autoresizing.All;ParticipantTable.Source=新的registrantTableSource(INSTALLcme.registeredPeople);添加(参与者表);我刚意识到你问的是textview。TextView是使用Xcode和xib文件创建的。[Outlet]MonoTouch.UIKit.UITextField tbLastName{get;set;}[Outlet]MonoTouch.UIKit.UITextField tbLastName{get;set;}