上記のサイトを参考にしながら、Objective-CでCustomcellを使用したいと思っています。
セルに値を設定するデータソースメソッドのところで
Swiftでは
/// セルに値を設定するデータソースメソッド(必須) func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { // セルを取得 let cell = tableView.dequeueReusableCellWithIdentifier("MyCell") as! CustomTableViewCell // セルに値を設定 cell.myImageView.image = UIImage(named: imageNames[indexPath.row]) cell.myTitleLabel.text = imageTitles[indexPath.row] cell.myDescriptionLabel.text = imageDescriptions[indexPath.row] return cell }
上記のように記述し、セルを取得するところで
これをやることによって「ここで取得するセル(let cell)は、自分で作ったCustomTableViewCellクラスだよ」とセルに覚え込ませます。
そうすることで、CustomTableViewCellに配置したUIImageViewやUILabelに値をセットする事が出来るようになります。
とあるのですが
これをObjective-Cではどのように記述すればよろしいでしょうか?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; if(!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"]; } return cell; }
現状上記のように記述しております。
どなたかご教示いただけましたら、幸いです。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/09/05 01:07