Предупреждение о табличном представлении не отображается - PullRequest
0 голосов
/ 08 марта 2011

У меня есть следующий код в UITableViewController:

#import "TaskTableController.h"
@implementation TaskTableController


- (void)viewDidLoad {
    theArray = [[NSArray alloc] initWithObjects:@"Apple",@"Pineapple",@"Banana",nil];
    [super viewDidLoad];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [theArray count];
}



- (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];
    }

    cell.textLabel.text = [theArray objectAtIndex:indexPath.row];    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Selected a row" message:[theArray objectAtIndex:indexPath.row] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
}


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


@end

Проблема в том, что, когда я нажимаю на ячейку, она выделяет ячейку, но никогда не показывает предупреждение. Есть что-то, чего мне не хватает? Внутри FirstView у меня есть табличное представление, которое табличное представление смотрит на объект табличного представления, класс которого установлен в TaskTableController.

1 Ответ

1 голос
/ 08 марта 2011

Я думаю, что вы забыли установить делегат UITableViewDelegate с FileOwner.

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