소스는 작성중 입니다.
//
// LanguageTableViewController.swift
// Table46
//
// Created by 컴퓨터소프트웨어학과 on 2016. 11. 10..
// Copyright © 2016년 sd. All rights reserved.
//
import UIKit
class LanguageTableViewController: UITableViewController {
var languageImages = [String]()
var languageNames = [String]()
var languageURLs = [String]()
override func viewDidLoad() {
super.viewDidLoad()
languageNames = ["Python",
"Java",
"Rust",
"Swift",
"Kotlin"]
languageURLs = ["https://namu.wiki/w/Python",
"https://namu.wiki/w/Java",
"https://namu.wiki/w/Rust",
"https://namu.wiki/w/스위프트",
"https://namu.wiki/w/코틀린"]
languageImages = ["python.png",
"java.png",
"rust.png",
"swift.png",
"kotlin.png"]
tableView.estimatedRowHeight = 50
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1 // 섹션 개수
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return languageNames.count // 셀(열) 개수
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("LanguageTableCell", forIndexPath: indexPath) as! LanguageTableViewCell
let row = indexPath.row
cell.languageLabel.font =
UIFont.preferredFontForTextStyle(UIFontTextStyleHeadline)
cell.languageLabel.text = languageNames[row]
cell.languageImage.image = UIImage(named: languageImages[row])
return cell // TableVeiwCell로 틀에 배열에 있는 값들을 각 셀에 채워 돌려줍니다.
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "ShowLanguageDetails" {
let detailViewController = segue.destinationViewController
as! LanguageDetailViewController
let myIndexPath = self.tableView.indexPathForSelectedRow!
let row = myIndexPath.row
detailViewController.detailURL = languageURLs[row]
}
}
/*
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath)
// Configure the cell...
return cell
}
*/
/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
} else if editingStyle == .Insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
//
// LanguageTableViewCell.swift
// Table46
//
// Created by 컴퓨터소프트웨어학과 on 2016. 11. 10..
// Copyright © 2016년 sd. All rights reserved.
//
import UIKit
class LanguageTableViewCell: UITableViewCell {
@IBOutlet weak var languageLabel: UILabel!
@IBOutlet weak var languageImage: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// LanguageTableViewCell.swift
// Table46
//
// Created by 컴퓨터소프트웨어학과 on 2016. 11. 10..
// Copyright © 2016년 sd. All rights reserved.
//
import UIKit
class LanguageTableViewCell: UITableViewCell {
@IBOutlet weak var languageLabel: UILabel!
@IBOutlet weak var languageImage: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// LanguageDetailViewController.swift
// Table46
//
// Created by 컴퓨터소프트웨어학과 on 2016. 11. 10..
// Copyright © 2016년 sd. All rights reserved.
//
import UIKit
class LanguageDetailViewController: UIViewController {
var detailURL: String?
@IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
if let address = detailURL {
print(address)
let webURL = NSURL(string: address)
let urlRequest = NSURLRequest(URL: webURL!)
webView.loadRequest(urlRequest)
}
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}