iListening_設計介面_prototype_第一階段_跳頁_傳值_倒數機制_頁面
http://www.popzitizh.com/
缺乏設計感時 在身旁的一個利器網站
最近一直在思考 註冊機制的存在
後來發現 註冊機制 主要是為了後續可以觀察消費者來源
和 所在地 等等 或者 統計 男女比 之類
年齡層 等等
後續可做許多應用 因此 後端所需要存取的這些使用者資訊是非常重要的
這次的課題是實作出
第一個頁面 跳至 第二個頁面(以及傳值)
倒數 機制 的程式 實作
在之前有探討到 關於跳頁實作的問題
http://coolmandiary.blogspot.tw/2017/03/iosuiview.html
這次遇到的第一個問題
跳頁難道只能 按按鈕 進行跳頁嗎?????
youtube上 林永堅老師 在 UIView 的介紹 中
https://www.youtube.com/watch?v=JxM3zNCdNIw&list=PLO5e_-yXpYLBvrAbZz0rnSOtv9qCzQs9P&index=6
提到了一個重點 UIView 下方
UILabel 、 UIImage 、 UIWindow 等等 都是 繼承於 UIView 這個父類
不過這個 Navigation Controller 雖然是能夠幫助我實踐 跳頁
但跟我想要呈現的方式不同
林永堅老師 他使用的這個跳頁方法
會在跳到 第二頁時 在上方出現 Back 的字眼返回鈕
該說貼心呢.... 還是......
//
// ViewController.swift
// iListening_version1
//
// Created by Abraham on 2017/4/7.
// Copyright © 2017年 Abraham. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
//取數值需加上 驚嘆號 !
@IBOutlet weak var playBtn : UIButton!
@IBOutlet weak var timeLabel : UILabel!
var Counter = 0.0;
var Timer = Foundation.Timer()
var IsPlaying = false
//
override func viewDidLoad() {
timeLabel.text = String(Counter)
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//for test
/*
@IBAction func showMessage()
{
let alertController = UIAlertController(title: "you have pressed" ,
message: "Hello World" ,
preferredStyle: UIAlertControllerStyle.alert)
alertController.addAction(UIAlertAction(title:"OK",style:UIAlertActionStyle.default,handler:nil))
present(alertController, animated: true , completion: nil)
}
*/
//第一版.按鈕事件添加
@IBAction func playButtonDidTouch(_ sender: AnyObject)
{
if(IsPlaying)
{
return
}
playBtn.isEnabled = false
Timer = Foundation.Timer.scheduledTimer(timeInterval: 0.001,
target: self, selector: #selector(ViewController.UpdateTimer), userInfo: nil,
repeats: true)
IsPlaying = true
}
func UpdateTimer()
{
Counter += 0.1
timeLabel.text = String(format: "%.1f" , Counter)
}
}
一些按鈕上配置的細節
心得:
在影片中 老師 是 教 大家如何利用
TableView 中的 Cell 去 進行 跳轉頁面
但是 我們其實 可以不一定要用 Cell
用一個 Button 也可以 概念是一樣的~~
留言
張貼留言