https://akira-watson.com/iphone/tableview_3_objective-c.html
上記サイトは、TableViewCell(以下、Cellとします)をクリックすることでViewControllerを
生成してそこに遷移し、ViewController上のImageViewに画像を表示させるコードを紹介しています。
表示される画像というのは、plistに格納されており、Cellをクリックすることで呼び出されます。
plistには、テキストデータも含まれています。テキストデータは、Cellのテキストとして動的に表示されています。
上記サイトを参考にして、Cellをクリックして生成されたViewController上のラベルに、
Cellのテキストを表示させる方法を模索しています。
そのためには上記サイトのコードのうち、何箇所かを書き換えなければいけませんが、
//ViewController.hの中身 @interface ViewController : UIViewController @property NSString *imageName; @property IBOutlet UIImageView *imageView;
を
//ViewController.hの中身 @interface ViewController : UIViewController @property NSString *textName; @property (weak, nonatomic) IBOutlet UILabel *lbText;
に書き換え、また、
// ViewController.mの中身 #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.imageView.image = [UIImage imageNamed:self.imageName]; // 画像のアスペクト比を維持しUIImageViewサイズに収まるように表示 [self.imageView setContentMode:UIViewContentModeScaleAspectFit]; }
というコードのうち、
self.imageView.image = [UIImage imageNamed:self.imageName];
を、画像ではなくテキストを表示させるものにしたいのですが、どうすれば良いでしょうか?
とりあえず試しにこんなものを書いてみたのですが・・・
self.lbLabel.text = [UITextFieldLabel textNamed:self.textName];
当然動きません。
以上、何卒よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/02/04 05:50
2015/02/05 02:04
2015/02/05 23:23
2015/02/06 04:59
2015/02/07 07:44