2010-01-19 4 views
0

내 탭 막대 템플릿 응용 프로그램의 중간에 tableview가 있습니다. 'routines'라는 NSMutableArray의 내용을 추가하고 싶습니다.TableView가 제대로 표시되지 않고 충돌하는 경우

여기 내 .H 파일

#import <UIKit/UIKit.h> 


@interface FirstViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> { 

NSMutableArray *routines; 
} 

@property (nonatomic, retain) NSMutableArray *routines; 

- (IBAction)showNewEventViewController; 



@end 

내하는 .m 파일입니다.

#import "FirstViewController.h" 
#import "NewEventViewController.h" 

@implementation FirstViewController 

@synthesize routines; 



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 

return [routines count]; 

} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
} 

// Set up the cell... 
NSString *cellValue = [routines objectAtIndex:indexPath.row]; 
[cell.textLabel setText:cellValue]; 

return cell; 
} 

내 객체 그냥 표시되지 않습니다

- (void)viewDidLoad { 

routines = [[NSMutableArray alloc] init]; 

[routines addObject:@"Hello"]; 
[routines addObject:@"Temp"]; 
[routines addObject:@"Temp2"]; 
[routines addObject:@"Temp3"]; 
[routines addObject:@"Temp4"]; 
self.navigationItem.title = @"test"; 


} 

의 viewDidLoad 방법. 보시다시피, 내가 추가했습니다

그리고 나는 그것을 모두 정확하게 엮었습니다.

내 앱을 열려고 할 때 (충돌이 발생하면) 충돌이 발생하고 다음 로그를 뱉어냅니다.

[Session started at 2010-01-19 17:57:01 +1300.] 
2010-01-19 17:57:03.563 Gym Buddy[12690:207] *** -[UITabBarController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x3b12450 
2010-01-19 17:57:03.564 Gym Buddy[12690:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UITabBarController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x3b12450' 
2010-01-19 17:57:03.577 Gym Buddy[12690:207] Stack: (
29295707, 
2538743049, 
29677627, 
29247094, 
29099714, 
4364410, 
4371786, 
4370783, 
3087322, 
3027833, 
3069268, 
3057823, 
55808688, 
55808111, 
55806150, 
55805242, 
2731769, 
2755464, 
2737875, 
2764981, 
37392081, 
29080448, 
29076552, 
2731625, 
2768899, 
9784, 
9638 
) 

나는 초심자 인 이래로 무엇이 잘못 될지 전혀 모른다.

고마워! 당신이 당신의 UITabBarController가 아니라 당신의 FirstViewController 객체가 될 수있는 테이블의 데이터 소스를 할당 것 같은

답변

2

는 것 같습니다. 그 두 번째 줄의 붙여 넣기 오류 메시지가 numberOfRows를 가져 오려고하지만 데이터 소스가이를 구현하지 못한다고 말합니다. IB에서 연결을 다시 확인하십시오.

+0

나는 IB에서 새로운 빈 NSObject를 생성하고 클래스에 넣었다. 그 것이 충돌을 해결했습니다. 하지만 여전히 내 개체가 테이블보기에 표시되지 않습니다 –

+0

아. 또한이 새 객체의 뷰를 윈도우 상자에 연결했습니다. –

관련 문제