Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > iOS TableView จะทำยังไงให้แสดงแค่ 10 รายการ หากเลื่อนลงไปดูรายการที่ 10 ให้โหลดเพิ่มอีก 10 รายการ



 

iOS TableView จะทำยังไงให้แสดงแค่ 10 รายการ หากเลื่อนลงไปดูรายการที่ 10 ให้โหลดเพิ่มอีก 10 รายการ

 



Topic : 107522



โพสกระทู้ ( 0 )
บทความ ( 0 )



สถานะออฟไลน์




IOS TableView จะทำยังไงให้แสดงแค่ 5 รายการ หากเลื่อนลงไปดูรายการที่ 5 ให้โหลดเพิ่มอีก 5 รายการ

TableView

ViewController.h

Code (Objective-C)
//
//  ViewController.h
//  testTableView462
//


#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@property NSMutableArray *category;
@property NSMutableArray *description;
@property NSMutableArray *thumbnails;

@end



ViewController.m
Code (Objective-C)
//
//  ViewController.m
//  testTableView462


#import "ViewController.h"
#import "MyCustomCell.h"  

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    _category = [[NSMutableArray alloc] init];
    [_category addObject:@"ประตูรีโมท"]; [_category addObject:@"ร้านอาหาร"];[_category addObject:@"เครื่องกรองน้ำ"];
    [_category addObject:@"เรื่องน่ารู้"];
    [_category addObject:@"อุปกรณ์ควบคุม"];
    [_category addObject:@"อุปกรณ์ล้อเลื่อน"];
    [_category addObject:@"เครื่องกรองน้ำดื่ม"];
    [_category addObject:@"รายการอื่นๆ"];
    [_category addObject:@"ข่าวภูมิภาค"];
    
    
    _description =[[NSMutableArray alloc] init];
    [_description addObject:@"ประตูควบคุมด้วยรีโมท"];
    [_description addObject:@"แนะนำร้านอาหารอร่อยๆ"];
    [_description addObject:@"เครื่องกรองน้ำทุกขนาด"];
    [_description addObject:@"เรื่องราวสาระน่ารู้"];
    [_description addObject:@"อะไหล่ อุปกรณ์ควบคุม"];
    [_description addObject:@"อุปกรณ์ประตูล้อเลื่อน"];
    [_description addObject:@"เครื่องกรองน้ำดื่มในบ้าน"];
    [_description addObject:@"รายการสินค้าอื่นๆ"];
    [_description addObject:@"รายการข่าวภูมิภาค"];
    
    _thumbnails = [[NSMutableArray alloc] init];
    [_thumbnails addObject:@"gate.jpg"];
    
    [_thumbnails addObject:@"thumb1.jpg"];
    [_thumbnails addObject:@"waterfilter.jpg"];
    [_thumbnails addObject:@"gate.jpg"]; [_thumbnails addObject:@"gateboard.jpg"];
    [_thumbnails addObject:@"gate_track.jpg"];[_thumbnails addObject:@"filter01.jpg"];
    [_thumbnails addObject:@"gate_track.jpg"];
    [_thumbnails addObject:@"filter01.jpg"];
 
}


- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    return [_category count];

}


- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier = @"MyCell";
    
    MyCustomCell *cell =
    [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
    
    if (cell == nil) {
        cell = [[MyCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
    }
    
    cell.cellTitle.text = [_category objectAtIndex:indexPath.row];

    cell.cellThumb.image = [UIImage imageNamed:[_thumbnails objectAtIndex:indexPath.row]];

    cell.cellDescription.text = [_description objectAtIndex:indexPath.row];
    NSString *sub3 = [NSString stringWithFormat: @"Hit %d", indexPath.row];
    cell.cellSub3.text = sub3;
    
    return cell;
}


- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellSelected = [_category objectAtIndex:indexPath.row];
    UIAlertView *messageAlert = [[UIAlertView alloc]
                                 initWithTitle:@"Row Selected"
                                 message:cellSelected
                                 delegate:nil
                                 cancelButtonTitle:@"OK" otherButtonTitles:nil];
    

    [messageAlert show];
    
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end



MyCustomCell.h

Code (Objective-C)
//
//  MyCustomCell.h
// 


#import <UIKit/UIKit.h>

@interface MyCustomCell : UITableViewCell

@property (strong, nonatomic) IBOutlet UIImageView *cellThumb;
@property (strong, nonatomic) IBOutlet UILabel *cellTitle;
@property (strong, nonatomic) IBOutlet UILabel *cellDescription;
@property (strong, nonatomic) IBOutlet UILabel *cellSub3;

@end



MyCustomCell.m

Code (Objective-C)
//
//  MyCustomCell.m
//  testTableView462
//


#import "MyCustomCell.h"

@implementation MyCustomCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end



ขอบคุณครับ



Tag : Mobile, iOS







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-04-07 08:50:41 By : frankenly View : 912 Reply : 2
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ลองเอา Code นี้ไปดูครับ

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Classic start method
    static NSString *cellIdentifier = @"MyCell";
    MyCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell)
    {
        cell = [[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MainMenuCellIdentifier];
    }

    MyData *data = [self.dataArray objectAtIndex:indexPath.row];
    // Do your cell customisation
    // cell.titleLabel.text = data.title;

    if (indexPath.row == [self.dataArray count] - 1)
        [self launchReload];
}


Code
http://stackoverflow.com/questions/20269474/uitableview-load-more-when-scrolling-to-bottom-like-facebook-application
http://code4app.net/ios/Refresh-and-load-more-Table/4f9555bb06f6e7ac71000000







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-04-07 19:04:18 By : mr.win
 


 

No. 2

Guest


ผมไม่เก่งอังกฤษ สะด้วยสิ้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-04-07 21:04:56 By : Frankenly
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : iOS TableView จะทำยังไงให้แสดงแค่ 10 รายการ หากเลื่อนลงไปดูรายการที่ 10 ให้โหลดเพิ่มอีก 10 รายการ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่