为什么我的细胞不会被填充?

时间:2014-09-23 22:29:20

标签: c# xamarin.ios xamarin

我试图在我的Xamarin.iOS项目中填充表格。使用RestSharp组件从API收集数据。我能够将我想要的字符串存储在string []数组中,但是当我尝试将它们添加到表格中时,它们就不会显示出来。为什么会这样?

FirstViewController.cs

List<string> urls = new List<string> ();
List<string> titles = new List<string> ();

string[] urlArray = new string[]{};
string[] titleArray = new string[]{};

var client = new RestClient("http://www.example.com/");
var request = new RestRequest(String.Format("api/?function=getNews&key=X"));

    client.ExecuteAsync (request, response => {
            JsonValue data = JsonValue.Parse(response.Content);
                for (var i = 0; i < data["result"].Count; i++){
                    String title = data["result"][i]["post_title"].ToString();
                    String url = data["result"][i]["guid"].ToString();
                    Console.WriteLine(title + " : " + url);
                    urls.Add(url);
                    titles.Add(title);
                }
                titleArray = titles.ToArray();
                urlArray = urls.ToArray ();
                table.Source = new TableSource(titleArray);
                InvokeOnMainThread ( () => {
                    Add (table);
        });
    });

TableSource.cs

0 个答案:

没有答案