UITableView щелкнув по элементу, открывая новый экран / вид / активность - PullRequest
1 голос
/ 28 марта 2011

У меня есть табличное представление (HomeViewController), состоящее из следующих элементов:

  1. местоположения

  2. Отчетность

  3. Настройка

У меня есть эти элементы в виде отдельных файлов (LocationViewController, ReportingView Controller и Setting ViewController). Теперь, если пользователь нажимает на местоположение, новый экран / действие / представление должны бытьоткрыть и то же самое для остальных предметов.Может кто-нибудь, пожалуйста, help.my код как:

    #import "HomePageController.h"  @implementation HomePageController
    @synthesize menuList, table;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

- (void)viewDidLoad
 {

    menuList=[[NSMutableArray alloc] initWithObjects:

              [NSArray arrayWithObjects:@"LOCATIONS",nil],

              [NSArray arrayWithObjects:@"REPORTING",nil], 

              [NSArray arrayWithObjects:@"SETTINGS",nil],

              [NSArray arrayWithObjects:@"PASSWORD",nil],

              [NSArray arrayWithObjects:@"HELP",nil],

              [NSArray arrayWithObjects:@"ABOUT",nil],

              [NSArray arrayWithObjects:@"SHARE",nil],
              nil];
    [self.navigationController setNavigationBarHidden:NO];  
    self.navigationController.navigationBar.tintColor=[UIColor blackColor]; 
    self.navigationController.navigationBar.barStyle=UIBarStyleBlackTranslucent;    
    self.title=@"CoinRead";     
    [table reloadData];
    [super viewDidLoad];
}

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView{
    return 1;
}

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

- (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section{
    return menuList.count;
}

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

    UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:CellIdentifier];

    if(cell == nil){

        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease];
    }

    cell.highlighted=NO;

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    NSArray *rowArray = [menuList objectAtIndex:indexPath.row];

    UILabel *nameLabel = [[[UILabel alloc] initWithFrame:CGRectMake(15, 8, 200, 20)]autorelease];

    nameLabel.text = [NSString stringWithFormat:@"%@",[rowArray objectAtIndex:0]];

    nameLabel.backgroundColor = [UIColor clearColor];

    nameLabel.shadowColor=[UIColor whiteColor];

    nameLabel.shadowOffset=CGSizeMake(0.0, 0.5);

    nameLabel.textColor = RGB(0,0,0);

    [nameLabel setFont:[UIFont boldSystemFontOfSize:16.0f]];

    [cell.contentView addSubview:nameLabel];

    return cell;
}

1 Ответ

0 голосов
/ 28 марта 2011

Реализуйте приведенный ниже метод UITableViewDelegate, чтобы получить событие выбора

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...