// // CardViewController.swift // Twear // // Created by yangbin on 2022/1/19. // import UIKit class CardViewController: UIViewController { @IBOutlet weak var tableView: UITableView! private let cardArray: [String] = ["微信", "QQ", "Facebook", "WhatsApp", "Twitter"] private let cardDic: [String: String] = ["微信": "push_wechat", "QQ": "push_qq", "Facebook": "push_Facebook", "WhatsApp": "push_WhatsApp", "Twitter": "push_Twitter"] lazy var footerView: UIView = { let view = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 45)) let label = UILabel(frame: CGRect(x: 12.5, y: 2.5, width: SCREEN_WIDTH-30, height: 40)) label.font = RegularFont(11) label.textColor = UIColor.rgbColorFromHex(0x808080) label.numberOfLines = 0 label.text = LocString("将名片绑定至您的手表里,随时随地添加新朋友") view.addSubview(label) return view }() override func viewDidLoad() { super.viewDidLoad() title = LocString("名片") tableView.register(UINib.init(nibName: "SettingCell3", bundle: Bundle.main), forCellReuseIdentifier: "SettingCell3") tableView.contentInset = UIEdgeInsets(top: 5, left: 0, bottom: 10, right: 0) tableView.tableFooterView = footerView // Do any additional setup after loading the view. } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */ } extension CardViewController: UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 50 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return cardArray.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "SettingCell3", for: indexPath) as! SettingCell3 let cardText = cardArray[indexPath.row] cell.titleLabel.text = LocString(cardText) cell.setImageView.image = UIImage(named: cardDic[cardText]!) return cell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let cell = tableView.cellForRow(at: indexPath) as! SettingCell3 cell.isSelected = false // let device = CurDevice // switch cardArray[indexPath.row] { // case "QQ": let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "CardDetailVC") as! CardDetailVC vc.app = cardArray[indexPath.row] navigationController?.pushViewController(vc, animated: true) // case "短信提醒": // let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "SMSRemindVC") // navigationController?.pushViewController(vc, animated: true) // case "应用提醒": // let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "APPRemindVC") // navigationController?.pushViewController(vc, animated: true) // case "健康提醒": // let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "HealthRemindVC") // navigationController?.pushViewController(vc, animated: true) // case "闹钟提醒": // let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "AlarmClockVC") // navigationController?.pushViewController(vc, animated: true) // default: // break // } } }