Guest User

Untitled

a guest
Jan 17th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. import UIKit
  2. import Parse
  3.  
  4. class DetailSoccerTableViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
  5.  
  6. @IBOutlet weak var imageSoccer: UIImageView!
  7. @IBOutlet weak var tableView: UITableView!
  8.  
  9.  
  10.  
  11.  
  12. var detailSoccer: Soccer!
  13.  
  14. var selectedSoccer = [Soccer]()
  15.  
  16.  
  17.  
  18. override func viewDidLoad() {
  19. super.viewDidLoad()
  20.  
  21.  
  22. title = detailSoccer.detailTitleS
  23.  
  24.  
  25. tableView.estimatedRowHeight = 288
  26. tableView.rowHeight = UITableViewAutomaticDimension
  27. tableView.separatorStyle = UITableViewCellSeparatorStyle.none
  28.  
  29. tableView.register(UINib(nibName:"SoccerTableViewCell",bundle:nil), forCellReuseIdentifier: "soccerCell")
  30.  
  31.  
  32. tableView.reloadData()
  33. loadMatchSoccer()
  34.  
  35.  
  36. // Do any additional setup after loading the view.
  37. }
  38.  
  39. override func viewWillAppear(_ animated: Bool) {
  40. super.viewWillAppear(animated)
  41. self.navigationController!.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
  42. self.navigationController?.navigationBar.shadowImage = UIImage()
  43. self.navigationController?.navigationBar.isTranslucent = true
  44. self.navigationController!.view.backgroundColor = UIColor.clear
  45. self.navigationController?.navigationBar.backgroundColor = UIColor.clear
  46.  
  47.  
  48. }
  49.  
  50.  
  51.  
  52. override func didReceiveMemoryWarning() {
  53. super.didReceiveMemoryWarning()
  54. // Dispose of any resources that can be recreated.
  55. }
  56.  
  57.  
  58. func numberOfSections(in tableView: UITableView) -> Int {
  59. return 1
  60. }
  61.  
  62.  
  63. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  64.  
  65. return selectedSoccer.count
  66. }
  67.  
  68.  
  69.  
  70.  
  71. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  72. let soccerCell = tableView.dequeueReusableCell(withIdentifier: "soccerCell", for: indexPath) as! SoccerTableViewCell
  73.  
  74. let selectedSoccerRow = selectedSoccer[indexPath.row]
  75. switch indexPath.row {
  76. case 0:
  77. soccerCell.titlePrognoz.text = "Описание:"
  78. soccerCell.textSoccer.text = selectedSoccerRow.textSoccer
  79.  
  80. case 1:
  81. soccerCell.titlePrognoz.text = "Прогноз на матч:"
  82. soccerCell.textSoccer.text = selectedSoccerRow.detailPrognozS
  83. default:
  84. break
  85. }
  86.  
  87. soccerCell.backgroundColor = UIColor.clear
  88. soccerCell.selectionStyle = UITableViewCellSelectionStyle.none
  89. return soccerCell
  90.  
  91. }
  92.  
  93.  
  94.  
  95.  
  96. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  97. return UITableViewAutomaticDimension
  98. }
  99.  
  100. func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
  101. return UITableViewAutomaticDimension
  102. }
  103.  
  104.  
  105.  
  106. func loadMatchSoccer() {
  107.  
  108. let query = Soccer.query() as! PFQuery<Soccer>
  109.  
  110.  
  111. query.findObjectsInBackground { (objects, error) in
  112. if error == nil {
  113. self.selectedSoccer = objects!
  114.  
  115.  
  116.  
  117. DispatchQueue.main.async(execute: {
  118. self.tableView.reloadData()
  119. })
  120.  
  121.  
  122.  
  123. } else {
  124. print(error!)
  125. }
  126. }
  127. }
  128. }
Add Comment
Please, Sign In to add comment