0

タブ バー アプリケーションの最初のタブにテーブル ビューがあります。次に、任意の行をクリックすると、secondviewController のビューをプッシュします。そしてラベルがあります。ラベルのテキストは、選択された行のテキストである必要があります。私はこれを試してみましたが、2番目のタブに入っていません:Sどうすればこれを行うことができますか??? また、secondViewController クラスには 3 つのビューがあります。

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

SecondViewController  *detailViewController = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil];
// ...
// Pass the selected object to the new view controller.
NSUInteger row2 = [indexPath row];
denemelik=row2;

[self.navigationController pushViewController:detailViewController animated:YES];
detailViewController.enyakinfirma.text= [ws2.CustomerName objectAtIndex:[indexPath row]]; 
NSLog(@"kontrol2 %@",ws2.CustomerName);

[detailViewController release];

}

4

1 に答える 1

0

テキストを入力したいenyakinfirmaのはあなただと思います。UILabelラベルを実際に作成してロードする前に、テキストをラベルに割り当てることはできません。そして、それは後で、新しいView Controllerをプッシュした後に起こります.

したがって、必要な@propertyこのテキストを追跡するために、別のを作成する必要があります。

// SecondViewController.h
@interface SecondViewController {
    NSString *customerName;
}    
@property (nonatomic, retain) NSString *customerName;
@end

ビュー コントローラを作成するときに、次のプロパティを割り当てます。

detailViewController.customerName = ...;

そして、View Controller のviewDidLoadメソッドでテキストを更新します。

-(void)viewDidLoad {
    // ...
    enyakinfirma.text = self.customerName;
}
于 2011-10-28T13:34:20.410 に答える