2012-04-27 3 views
-4
#import <UIKit/UIKit.h> 

@interface tableview : UIViewController<UITableViewDataSource> 

{ 
    NSArray *listOfItems; 
} 
@property(nonatomic,retain) NSArray *listOfItems; 

@end 


#import "tableview.h" 

@implementation tableview 
@synthesize listOfItems; 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) 
    { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier ]autorelease]; 
    } 

    //NSString *cellValue = [listOfItems objectAtIndex:indexPath.row]; 
    cell.textLabel.text = [listOfItems objectAtIndex:indexPath.row]; 
    return cell; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return 3; 
} 



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)didReceiveMemoryWarning 
{ 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

    // Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    listOfItems = [[NSArray alloc] initWithObjects:@"first",@"second",@"third", nil]; 

    //listOfItems = [[NSMutableArray alloc]init]; 
    // [listOfItems addObject:@"first"]; 
    //[listOfItems addObject:@"second"]; 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view from its nib. 
} 

-(void)dealloc 
{ 
    [listOfItems release]; 
    [super dealloc]; 
} 



@end 

2012-04-27 13 : 33 : 23.276의 tableview 시험 [438 : 207] - [UIView의있는 tableView : numberOfRowsInSection :] : 미정 선택기 인스턴스에 전송 0x6855500
2,012 -04-27 13 : 33 : 23.362의 tableview 시험 [438 : 207] * 의한 캐치되지 않는 예외 'NSInvalidArgumentException'응용 프로그램 종료, 이유 :
'- [UIView의있는 tableView : numberOfRowsInSection :] 인스턴스 0x6855500 전송 인식 선택기
'
*
첫 번째 호출 스택 호출 :
은 (0x13bb052 0x154cd0a는 0x1321f00을 0x13bcced 0x1321ce2 0x1ecf2b 0x1ef722 0x9f7c7 0x9f2c1 0xa228c 0xa6783 0x51322 0x13bce72 0x1d6592d 0x1d6f827 0x1cf5fa7 0x1cf7ea6 0x1d8330c 0x23530 0x138f9ce 0x1326670 0x12f24f6 0x12f1db4 0x12f1ccb 0x12a4879 0x12a493e 0x12a9b 0x2282 0x21f5) exceptionCurrent 언어 던지는라고 종료 : 자동; 현재 objective-c (gdb)프로그램 수신 신호 SIGABRT (엑스 코드)

+0

테이블 뷰의 데이터 소스 및 대리인 속성이 올바르게 설정되지 않았습니다. 사용중인 내용과 충돌하는 이유를 더 자세히 추가해야합니다. – rishi

+0

문제는 여기에 있습니다 : [UIView tableView : numberOfRowsInSection :] 인식 할 수없는 선택기가 인스턴스 0x6855500로 전송되었습니다. 이 테이블 뷰를 사용하는 코드를 게시하십시오 .. – Lolloz89

+0

m 버튼을 포함하는 뷰에서 전송하려고합니다. 버튼을 누르면 테이블 뷰가 포함 된 새로운 뷰로 전송됩니다.하지만 매번 내가이 오류가 디버깅 ... 나는 IOS 시뮬레이터를 재설정 시도했는데 작동하지 않습니다 – manish1990

답변

-1

코드가 완료되지 않았습니다. 귀하의 "tableView"진짜 UITableView되지 않습니다, 그것은 UIViewController이야!

h 파일과 xib 파일에 UITableView 인스턴스가 있어야하며 서로 링크하고 UITableViewDelegate proprty를 UIViewcontroller 클래스로 설정해야합니다. 난 당신이 놓친 생각 UIView의

0

@interface에있는 tableview를 기본 jQuery과 체크 아웃 (또는있는 UITableViewController) 샘플하시기 바랍니다 UITableViewDelegate.

0

를 사용해보십시오 .... 대신의 UIViewController의

을의 UIViewController :

은 ...

관련 문제