0
numberOfRowsInSection starts with last sectionこれは重複して見えるかもしれませんが、提供されたソリューションは私からはうまくいかず、遠くに尋ねられ、Objective-Cでした。 AFAIKの言語はそれとは関係ありません。テーブルビューの最後のセクションはnumberOfRowsInSectionから始まります。
ステップ:
- コールAPI
- 配列への応答を追加 - 10の結果
- リロード表
numberOfRowsInSections
が呼び出されます。numberOfRowsInSections
プリントsection: 9 section: 0 section: 1 section: 2 section: 3 section: 4 section: 5 section: 6 section: 7 section: 8
で
print("section: \(section)")
私は各セクション内の行数が異なるにしたいので、それは望ましくない動作です。
numberOfRowsInSections
は各セクション内のセル数を決定するため、各アレイの特定の値に基づいてセクション数をカウントします。
応答:
{
count = 10;
"post_results" = (
{
attachment = "";
category = "An Act of Kindness";
"comments_count" = 5;
description = xjjxjsj;
"last_comment" = {
"comment_date" = "2016-09-13 08:24:38";
"comment_id" = 199;
description = "dddg\n";
"user_picture" = "/uploads/2016/09/popup-40x40.png";
username = testing1;
};
"likes_count" = 0;
"post_date" = "2016-09-13 07:59:17";
"post_id" = 1866;
"share_count" = "";
title = jdjsjsj;
"upload_type" = 0;
"user_image" = "/uploads/2016/09/popup-40x40.png";
"user_name" = testing1;
},
{
attachment = "";
category = "In The News";
"comments_count" = 6;
description = "check timing";
"last_comment" = {
"comment_date" = "2016-09-13 10:05:11";
"comment_id" = 207;
description = "hdhd\n";
"user_picture" = "/uploads/2016/09/popup-40x40.png";
username = testing1;
};
"likes_count" = 0;
"post_date" = "2016-09-13 07:06:46";
"post_id" = 1864;
"share_count" = "";
title = "new post";
"upload_type" = 0;
"user_image" = "/uploads/2016/09/popup-40x40.png";
"user_name" = testing1;
},
{
attachment = "";
category = "An Act of Kindness";
"comments_count" = 2;
description = "timer testing";
"last_comment" = {
"comment_date" = "2016-09-13 10:01:41";
"comment_id" = 201;
description = "hddn\n";
"user_picture" = "/uploads/2016/09/popup-40x40.png";
username = testing1;
};
"likes_count" = 0;
"post_date" = "2016-09-13 06:56:36";
"post_id" = 1862;
"share_count" = "";
title = hiii;
"upload_type" = 0;
"user_image" = "/uploads/2016/09/popup-40x40.png";
"user_name" = testing1;
},
{
attachment = "";
category = "An Act of Kindness";
"comments_count" = 0;
description = Hloo;
"last_comment" = {
"comment_date" = "";
"comment_id" = "";
description = "";
"user_picture" = "";
username = "";
};
"likes_count" = 0;
"post_date" = "2016-09-13 06:54:48";
"post_id" = 1860;
"share_count" = "";
title = testing;
"upload_type" = 0;
"user_image" = "/uploads/2016/09/popup-40x40.png";
"user_name" = testing1;
},
{
attachment = "";
category = "Making a Difference";
"comments_count" = 0;
description = TestContentdfdf899;
"last_comment" = {
"comment_date" = "";
"comment_id" = "";
description = "";
"user_picture" = "";
username = "";
};
"likes_count" = 0;
"post_date" = "2016-09-13 06:54:14";
"post_id" = 1858;
"share_count" = "";
title = TestTitleerer899;
"upload_type" = 0;
"user_image" = "/uploads/2016/09/popup-40x40.png";
"user_name" = max57;
},
{
attachment = "/uploads/2016/09/Koala6-440x330.jpg";
category = "Making a Difference";
"comments_count" = 0;
description = TestContentdfdf89;
"last_comment" = {
"comment_date" = "";
"comment_id" = "";
description = "";
"user_picture" = "";
username = "";
};
"likes_count" = 0;
"post_date" = "2016-09-13 06:49:07";
"post_id" = 1855;
"share_count" = "";
title = TestTitleerer89;
"upload_type" = 1;
"user_image" = "/uploads/2016/09/popup-40x40.png";
"user_name" = max57;
},
{
attachment = "www.praizbuk.com";
category = "An Act of Kindness";
"comments_count" = 0;
description = "";
"last_comment" = {
"comment_date" = "2016-09-13 08:16:01";
"comment_id" = 194;
description = "jddj\n";
"user_picture" = "/uploads/2016/09/popup-40x40.png";
username = testing1;
};
"likes_count" = 1;
"post_date" = "2016-09-09 07:12:44";
"post_id" = 1846;
"share_count" = "";
title = db;
"upload_type" = 3;
"user_image" = "/uploads/2016/09/popup-40x40.png";
"user_name" = kkk;
},
{
attachment = "/uploads/2016/09/dummy3.mp4";
category = "An Act of Kindness";
"comments_count" = 1;
description = xbbdbd;
"last_comment" = {
"comment_date" = "2016-09-09 07:17:36";
"comment_id" = 192;
description = "uugh\n";
"user_picture" = "/2016/09/popup-40x40.png";
username = kkk;
};
"likes_count" = 1;
"post_date" = "2016-09-09 06:19:20";
"post_id" = 1842;
"share_count" = "";
title = zyhh;
"upload_type" = 2;
"user_image" = "/uploads/2016/09/popup-40x40.png";
"user_name" = kkk;
},
{
attachment = "/uploads/2016/09/dummy2.mp4";
category = "In The News";
"comments_count" = 0;
description = "new video uploaded";
"last_comment" = {
"comment_date" = "";
"comment_id" = "";
description = "";
"user_picture" = "";
username = "";
};
"likes_count" = 0;
"post_date" = "2016-09-09 05:49:48";
"post_id" = 1838;
"share_count" = "";
title = "my video";
"upload_type" = 2;
"user_image" = "/uploads/2016/09/popup-40x40.png";
"user_name" = kkk;
},
{
attachment = "";
category = "An Act of Kindness";
"comments_count" = 0;
description = Vdfdfdfdfd;
"last_comment" = {
"comment_date" = "";
"comment_id" = "";
description = "";
"user_picture" = "";
username = "";
};
"likes_count" = 0;
"post_date" = "2016-09-08 12:00:24";
"post_id" = 1836;
"share_count" = "";
title = fff;
"upload_type" = 0;
"user_image" = "/uploads/2016/09/popup-40x40.png";
"user_name" = kkk;
}
);
status = ok;
}
そして、テーブル表示方法は次のとおりです。
なぜあなたに問題が発生していますか? – Larme
UITableViewDataSourceデリゲートを正しく実装していれば、どのセクションが最初に要求されても関係なく動作するはずです。あなたのコードのどこかに問題があります。誰かがあなたを助けることができるかもしれないかもしれません。 – Avt
@Larme - 質問を更新しますか? –