TableView не отображается правильно и вылетает, - PullRequest
0 голосов
/ 19 января 2010

У меня есть таблица в середине моего шаблона панели вкладок .. Я хотел добавить содержимое NSMutableArray под названием «рутины».

Вот мой .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;
}

и метод viewDidLoad

- (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";


}

Мои объекты просто не отображаются. Как видите, я добавил

и я все правильно подключил в IB.

Когда я пытаюсь открыть свое приложение (возврат), оно вылетает и выдает следующий журнал

 [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
)

Понятия не имею, что происходит, так как я новичок.

Спасибо, ребята!

Sam

1 Ответ

2 голосов
/ 19 января 2010

Похоже, вы назначили источник данных вашей таблицы в качестве вашего UITabBarController, а не объекта FirstViewController.Во второй строке вашего вставленного сообщения об ошибке говорится, что он пытается получить numberOfRows, но его источник данных не реализует его.Дважды проверьте ваши соединения в IB.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...