//
// RecipeViewController.swift
// InitialOfApp
//
// Created by Á¤¼ÒÇâ on 2018. 9. 16..
// Copyright © 2018³â SoHyang. All rights reserved.
//
import UIKit
class RecipeViewController : UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var recipe_tableview: UITableView!
var Category_Basic = ["CeleryJuice", "AppleJuice", "CarrotJuice", "GrapeJuice", "CabbageJuice", "SpinachJuice", "BellPepperJuice", "CarrotNCeleryJuice", "DetoxGreenJuice", "KaleJuice"]
var Category_Nutritious = ["ChocolateCashewMilk", "LOHASWheatgrassJuice","SoothingPearGingerJuice", "SoyMilk", "BroccoliPorridge", "TomatoSoup", "AlmondMilk", "RedVitaminRadishJuice", "CashewMilk"]
var Category_Coktail = ["KiwiMax","BerryBerryJuice", "MangoTangoCoulis", "TropicalFantasyMix", "TropicalMix", "PinkGrapefruitade", "GreenLemonade"]
var Category_Smoothies = ["KiwiSorbet", "BlueberrySmoothie","BananaYogurtGelato", "BerryDelight", "StrawberrySorbet", "CacaoAvocadoBananaSmoothie", "CarrotBananaSmoothie", "MelonBananaSmoothie", "CashewCranberrySmoothie", "CreamyPumpkinSmoothie", "CranberrySorbet"]
var ListName = "Name"
var selectedindex = 0
var sectionnum = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.title = "Recipe"
recipe_tableview.dataSource = self
recipe_tableview.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var rows: Int!
switch section{
case 0:
rows = 10
break
case 1:
rows = 9
break
case 2:
rows = 7
break
case 3:
rows = 11
break
default:
break
}
return rows
}
func numberOfSections(in tableView: UITableView) -> Int {
return 4
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
var headerLabel: String!
switch section {
case 0:
headerLabel = "Basic Juices & Vegetable Juices"
break
case 1:
headerLabel = "Nutritious Juices & Baby Food"
break
case 2:
headerLabel = "Cool Fruit Juices & Cocktails"
break
case 3:
headerLabel = "Smoothies & Frozen Desserts"
break
default:
break
}
return headerLabel
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "RecipeListCell", for: indexPath) as! RecipeListCell
selectedindex = indexPath.item
sectionnum = indexPath.section
switch sectionnum {
case 0:
ListName = Category_Basic[selectedindex]
break
case 1:
ListName = Category_Nutritious[selectedindex]
break
case 2:
ListName = Category_Coktail[selectedindex]
break
case 3:
ListName = Category_Smoothies[selectedindex]
break
default:
break
}
cell.R_label.text = ListName
// cell.R_image.image = UIImage(named: ListName)
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 65
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
selectedindex = indexPath.item
sectionnum = indexPath.section
switch sectionnum {
case 0:
ListName = Category_Basic[selectedindex]
break
case 1:
ListName = Category_Nutritious[selectedindex]
break
case 2:
ListName = Category_Coktail[selectedindex]
break
case 3:
ListName = Category_Smoothies[selectedindex]
break
default:
break
}
performSegue(withIdentifier: "DetailedRecipesegue", sender: self)
}
}
±¸ºÐ | ³»¿ë |
---|---|
À ±Û | TableView_tablecell |
¾Æ·§±Û | To receive recipe information from server |