2016-09-13 6 views
0

numberOfRowsInSection starts with last sectionこれは重複して見えるかもしれませんが、提供されたソリューションは私からはうまくいかず、遠くに尋ねられ、Objective-Cでした。 AFAIKの言語はそれとは関係ありません。テーブルビューの最後のセクションはnumberOfRowsInSectionから始まります。

ステップ:

  1. コールAPI
  2. 配列への応答を追加 - 10の結果
  3. リロード表
  4. 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; 
    } 
    

    そして、テーブル表示方法は次のとおりです。

  • +0

    なぜあなたに問題が発生していますか? – Larme

    +2

    UITableViewDataSourceデリゲートを正しく実装していれば、どのセクションが最初に要求されても関係なく動作するはずです。あなたのコードのどこかに問題があります。誰かがあなたを助けることができるかもしれないかもしれません。 – Avt

    +1

    @Larme - 質問を更新しますか? –

    答えて

    0

    応答パラメータタイプを持ついくつかの問題がありました。

    @Avtとして最終的な結論は、コメントで述べている:

    正しく実装UITableViewDataSourceは/それが最初に要求されているセクションに関係なく動作するはず委任する場合。

    関連する問題