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/iPhone Table View and Table View Cell - Custom Cell Column ทำตามแล้ว errorครับ



 

iOS/iPhone Table View and Table View Cell - Custom Cell Column ทำตามแล้ว errorครับ

 



Topic : 113946



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



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




Error นี้ไม่รู้แก้ที่ไหนครับ ผมทำตามตัวอย่างแล้วครับ

พอผมลบ displayCreateDate มันก็ขึ้น displayDescriptionครับ

2015-01-23 11:04:16.366 Test4[2663:56453] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x7fb94144f330> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key displayCreateDate.'



ViewController.m
#import "ViewController.h"
#import "CustomTableCell.h"

@interface ViewController ()
{
    NSMutableArray *myObject;
    
    // A dictionary object
    NSDictionary *dict;
    
    // Define keys
    NSString *images;
    NSString *name;
    NSString *description;
    NSString *createdate;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    // Define keys
    images = @"Images";
    name = @"Name";
    description = @"Description";
    createdate = @"CreateDate";
    
    
    // Create array to hold dictionaries
    myObject = [[NSMutableArray alloc] init];
    
    dict = [NSDictionary dictionaryWithObjectsAndKeys:
            @"1.jpg", images,
            @"Girl 1", name,
            @"Girl 1 Description", description,
            @"01-Nov-2012 12:00", createdate,
            nil];
    [myObject addObject:dict];
    
    
    dict = [NSDictionary dictionaryWithObjectsAndKeys:
            @"2.jpg", images,
            @"Girl 2", name,
            @"Girl 2 Description", description,
            @"01-Nov-2012 13:00", createdate,
            nil];
    [myObject addObject:dict];
    
    
    dict = [NSDictionary dictionaryWithObjectsAndKeys:
            @"3.jpg", images,
            @"Girl 3", name,
            @"Girl 3 Description", description,
            @"01-Nov-2012 14:00", createdate,
            nil];
    [myObject addObject:dict];
    
    dict = [NSDictionary dictionaryWithObjectsAndKeys:
            @"4.jpg", images,
            @"Girl 4", name,
            @"Girl 4 Description", description,
            @"01-Nov-2012 15:00", createdate,
            nil];
    [myObject addObject:dict];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return myObject.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    static NSString *CellIdentifier = @"Cell";
    
    CustomTableCell *cell = (CustomTableCell *) [tableView dequeueReusableCellWithIdentifier : CellIdentifier];
    
    if (cell == nil)
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomTableCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
    
    
    NSDictionary *tmpDict = [myObject objectAtIndex:indexPath.row];
    
    UIImage* theImage = [UIImage imageNamed:[tmpDict objectForKey:images]];
    
    cell.displayImage.image = theImage;
    cell.displayName.text = [tmpDict objectForKey:name];
    cell.displayDescription.text = [tmpDict objectForKey:description];
    cell.displayCreateDate.text = [tmpDict objectForKey:createdate];
    
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}

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




ViewController.h
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@property (retain, nonatomic) IBOutlet UITableView *myTable;

@end


CustomTableCell.h
#import <UIKit/UIKit.h>

@interface CustomTableCell : UITableViewCell
@property (nonatomic, strong) IBOutlet UIImageView *displayImage;
@property (nonatomic, strong) IBOutlet UILabel *displayName;
@property (nonatomic, strong) IBOutlet UILabel *displayDescription;
@property (nonatomic, strong) IBOutlet UILabel *displayCreateDate;
@end




CustomTableCell.m
#import "CustomTableCell.h"

@implementation CustomTableCell
@synthesize displayImage = _displayImage;
@synthesize displayName = _displayName;
@synthesize displayDescription = _displayDescription;
@synthesize displayCreateDate = _displayCreateDate;

- (void)awakeFromNib {
    // Initialization code
    
    
}

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

    // Configure the view for the selected state
}

@end





Tag : Mobile







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-01-23 11:16:14 By : crisisbank View : 864 Reply : 3
 

 

No. 1



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

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

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

Quote:
cell.displayCreateDate


มันน่าจะหาตัวนี้ไม่เจอน่ะครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-01-23 11:42:29 By : mr.win
 


 

No. 2



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



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


อันนี้เป็นหน้าเชื่อมครับ

error1

error2
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-01-23 11:56:56 By : crisisbank
 

 

No. 3



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

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

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

ผมว่าในบทความก็ละเอียดแล้วน่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-01-25 14:50:57 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : iOS/iPhone Table View and Table View Cell - Custom Cell Column ทำตามแล้ว errorครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 02
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 อัตราราคา คลิกที่นี่