###前提・実現したいこと
質問をご覧いただきまして、ありがとうございます。
現在、TableViewをコードで画面サイズに合わせてサイズを変えて表示しているのですが、
画面のサイズが変わっても、cellのwidthは変わらず320.0のままになってしまいます。
こちらの投稿を参照し、CustomCellを使えば実装可能かと思い、
試してみたのですが、
上のスクリーンショットのように、背景は画面いっぱいに伸びたのですが、accessoryが以前の位置にそのまま配置されてしまいます。
これを改善する方法がありましたら、ご教授いただきたく存じます。
よろしくお願いいたします。
下にソースコードを記載いたします。
ViewController.swift
//tableViewの横幅はview.frame.widthで画面サイズに合わせています。 //================================== tableViewWidth = self.view.frame.width //================================== //tableView dataの表示 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)->UITableViewCell { let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Cell") let object = array[indexPath.row] cell.textLabel?.text = titleArr[indexPath.row] cell.detailTextLabel?.text = dateArr[indexPath.row] cell.accessoryType = UITableViewCellAccessoryType.DetailDisclosureButton print("cell width is \(cell.frame.size.width)") print("tableView width is \(tableViewWidth)") return cell }
回答1件
あなたの回答
tips
プレビュー