2015-09-19 3 views
-1

Мой tableViewcell находится в массиве, и я хочу, чтобы выбрать ячейку дневник, из которого я должен перейти к следующему screen.i не знаю, что реализовать в сделал выберите строку method.please помочь мнеUITableView переход клеток

table=[[UITableView alloc]init]; 
    table.frame=CGRectMake(0, 0, 250, CGRectGetHeight(self.view.frame)); 
    table.delegate=self; 
    table.dataSource=self; 
    table.backgroundColor=RGBCOLOR(255,255,255); 
    tabledata=[NSMutableArray arrayWithObjects:@"Me and My stuff",@"Upgrade Membership",@"Diary",@"Progress",@"Friends",@"My awards and points",@"Messages",@"Blogs",@"Fun stuff",@"Remainders",@"Settings",@"Signout",nil]; 
    table.backgroundColor=RGBCOLOR(255,239,213); 
    table.sectionFooterHeight=44; 
    table.sectionHeaderHeight=44; 
    table.separatorStyle=UITableViewCellSeparatorStyleNone; 
    [self.view addSubview:table]; 
    self.view.backgroundColor=RGBCOLOR(255,239,213); 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    static NSString *cellidentifier [email protected]"table"; 
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellidentifier]; 
    if (cell==nil) { 
     cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellidentifier]; 
     cell.opaque=NO; 
     cell.backgroundColor=RGBCOLOR(255,239,213); 
     cell.textLabel.textColor=RGBCOLOR(32,178,170); 
     cell.selectionStyle=UITableViewCellSelectionStyleBlue; 

    } 

    cell.textLabel.text=[tabledata objectAtIndex:indexPath.row]; 


    return cell; 


} 


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 



} 
+0

RU с помощью раскадровки, если да, то показать свою ячейку для метода rowatindex –

+0

Нет я не использую раскадровки ... все сделано программно – Arun

+0

ok показать вашу опцию donefinishlaunch и cellfor rowatindexpath –

ответ

0

предположить, что TableView содержит в нашем первом контроллере представления

1. SecondViewController.h

@property(nonatomic, strong) NSString *fullName; 

2. SecondViewController.m

@synthisize fullName; 

- (void)viewDidLoad 
{ 

NSLog(@"name ==%@",fullName); 


[super viewDidLoad]; 

} 

3. FirstViewController.m

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

if (indexPath.row==2) // this is diary cell 
{ 
SecondViewController *temp = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; 

temp.fullName=[tabledata objectAtIndex:indexPath.row]; 

[self.navigationController pushViewController:temp animated:YES]; 

} 
else 
{ 
// do nothing 
} 
} 
+0

chec k ответ –

+0

Nope его не работает .... я просто хочу выбрать дневник, который находится в объектах массива – Arun

+0

@Arun - как узнать, в каком объекте содержится дневник, это обычный способ для push-данных, используя прогатически –