Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- import Parse
- class DetailSoccerTableViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
- @IBOutlet weak var imageSoccer: UIImageView!
- @IBOutlet weak var tableView: UITableView!
- var detailSoccer: Soccer!
- var selectedSoccer = [Soccer]()
- override func viewDidLoad() {
- super.viewDidLoad()
- title = detailSoccer.detailTitleS
- tableView.estimatedRowHeight = 288
- tableView.rowHeight = UITableViewAutomaticDimension
- tableView.separatorStyle = UITableViewCellSeparatorStyle.none
- tableView.register(UINib(nibName:"SoccerTableViewCell",bundle:nil), forCellReuseIdentifier: "soccerCell")
- tableView.reloadData()
- loadMatchSoccer()
- // Do any additional setup after loading the view.
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- self.navigationController!.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
- self.navigationController?.navigationBar.shadowImage = UIImage()
- self.navigationController?.navigationBar.isTranslucent = true
- self.navigationController!.view.backgroundColor = UIColor.clear
- self.navigationController?.navigationBar.backgroundColor = UIColor.clear
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- func numberOfSections(in tableView: UITableView) -> Int {
- return 1
- }
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return selectedSoccer.count
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let soccerCell = tableView.dequeueReusableCell(withIdentifier: "soccerCell", for: indexPath) as! SoccerTableViewCell
- let selectedSoccerRow = selectedSoccer[indexPath.row]
- switch indexPath.row {
- case 0:
- soccerCell.titlePrognoz.text = "Описание:"
- soccerCell.textSoccer.text = selectedSoccerRow.textSoccer
- case 1:
- soccerCell.titlePrognoz.text = "Прогноз на матч:"
- soccerCell.textSoccer.text = selectedSoccerRow.detailPrognozS
- default:
- break
- }
- soccerCell.backgroundColor = UIColor.clear
- soccerCell.selectionStyle = UITableViewCellSelectionStyle.none
- return soccerCell
- }
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return UITableViewAutomaticDimension
- }
- func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
- return UITableViewAutomaticDimension
- }
- func loadMatchSoccer() {
- let query = Soccer.query() as! PFQuery<Soccer>
- query.findObjectsInBackground { (objects, error) in
- if error == nil {
- self.selectedSoccer = objects!
- DispatchQueue.main.async(execute: {
- self.tableView.reloadData()
- })
- } else {
- print(error!)
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment