This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
let numOfFruits = fruits.count | |
return numOfFruits | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = UITableViewCell() | |
cell.textLabel?.text = fruits[indexPath.row] | |
return cell | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
let alert = UIAlertController(title: "Fruits", message: "This fruit is \(fruits[indexPath.row])", preferredStyle: UIAlertController.Style.alert) | |
let okButton = UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil) | |
alert.addAction(okButton) | |
self.present(alert, animated: true, completion: nil) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func nextButtonClicked(_ sender: Any) { | |
performSegue(withIdentifier: "toSecondVC", sender: nil) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
if segue.identifier == "toSecondVC" { | |
//as ile casting | |
let destination = segue.destination as! SecondViewController | |
destination.myName = name | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
super.viewDidLoad() | |
imageView.isUserInteractionEnabled = true // Görseli tıklanabilir hale getirdik. | |
//Gesture Recognizer'ı oluşturup action kısmında içine "changePic" fonskiyonunu gönderdik | |
let changeGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(changePic)) | |
//Daha sonra Gesture Recognizer'ı görselimze ekledik. | |
imageView.addGestureRecognizer(changeGestureRecognizer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objc func changePic() { | |
if isOldCeza == true { | |
imageView.image = UIImage(named: "cezaeski") | |
myLabel.text = "Ceza 2007" | |
isOldCeza = false | |
} else { | |
imageView.image = UIImage(named: "cezayeni") | |
myLabel.text = "Ceza 2020" | |
isOldCeza = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
super.viewDidLoad() | |
let keyboardGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(hideKeyboard)) // Gesture Recognizer'ı oluşturup içine hideKeyboard fonksiyonumuzu gönderdik. | |
view.addGestureRecognizer(keyboardGestureRecognizer) // Gesture Recognizer'ı tüm görünüme ekledik. | |
} | |
@objc func hideKeyboard() { | |
view.endEditing(true) //Klavyeyi kapatmamızı sağlayan fonksiyon. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getLyric() { | |
// Hedef URL'yi tanımlıyoruz | |
let url = URL(string: "https://api.kanye.rest/?format=text") | |
do { | |
//URL ile ulaştığımız veriyi String olarak alıyoruz. | |
let contents = try String(contentsOf: url!) | |
//String değeri text view'a gönderiyoruz. | |
textView.text = "\"\(contents)\"" | |
} catch { | |
// İçerik yüklenemez ise |
OlderNewer