0

1 つのセルをクリックすると UItableview が表示され、セル内のデータを取得したいので、別のコントローラーで UIlabel に割り当てて表示する必要があります。

そのコントローラーには、セルデータをそれに更新したいUIlabelがあります。

誰でも私がこれに慣れていないのを手伝ってもらえますか

(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];    
           }
    cell.textLabel.text=[array objectAtIndex:indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    Companydetails *details1= [[Companydetails alloc] initWithNibName:@"Companydetails" bundle:nil];
    details1.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:details1 animated:NO];
    [details1 release]; 
    UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];


}
4

2 に答える 2

0

2 番目のビュー コントローラーで、UITextField Like のプロパティを作成します。

.h file
@property (nonatomic,retain) UITextField *txtField;

.m file
@synthesize txtField;

現在のクラスで、そのビュー コントローラーを提示する場所から、2 番目のビュー コントローラーの UITextField の値を設定します。

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

    UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
    Companydetails *details1= [[Companydetails alloc] initWithNibName:@"Companydetails" bundle:nil];
    details1.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    details1.txtField.text = cell.textLabel.text. 
    [self presentModalViewController:details1 animated:NO];
    [details1 release]; 



}
于 2013-02-02T06:42:45.913 に答える
0

これを試して:

SeconView.h で

NSString *passValue;
@property(nonatomic,retain) NSString *passValue;

SecondView.m 内

@synthesize passValue;

FirstView.m 内

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

    Companydetails *details1= [[Companydetails alloc] initWithNibName:@"Companydetails" bundle:nil];
    details1.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
details1.passValue=[array objectAtIndex:indexPath.row];
    [self presentModalViewController:details1 animated:YES];


}
于 2013-02-02T09:24:04.950 に答える