8.4 组织播放器

控件

目前为止学的控件有UIlabel、UIProgress、UIImage、UIbutton、UItableView
各个空间的继承关系
  1. UILabel -> UIView ->UIResponder -> NSObject

  2. UIButton -> UIControl ->UIView

  3. UIImagerView -> UIView

  4. UIButton -> UIControl -> UIView //直接设置动作,触发事件

  5. UITableView -> UIScrollView //协议或闭包获取数据

HTTP请求

let path = "[http://divein.club"](http://divein.club")

let url = NSURL(String: path)

let task = NSURLSEssion.sharedSession().dataTaskWithURL
(url!, completionHandle:{
        (data, response, error ) in
        if error == nil {
            if let httpResponse = response as?
            NSHTTPURLResponse {
            if httpResponse .statusCode == 200
            {
                if let d = data {
                    do {
                        let array = try! NSJSONSerialization.
                        jsonObjectWithData(d, options: .AllowFragments ) as?
                        Array<NSDictionary>
                     }    
                }
            }
        }
    }  )
}                     
task.resume( )

百分号转义

let p = "[http://divein.club./中国"](http://divein.club./%E4%B8%AD%E5%9B%BD%22)  非法
let origin: NSString = "中国"
let encode = origin.stringByAddingPercentEscape( )
let p = "[http://divein.club/"](http://divein.club/%22) + encode

音频播放

import AVFoundation

let path = "/..../a.mp3"
let url = NSURL(fileWithPath: path)
let player = try! AVAudioPlayer(contentOfURL: url)
player.delegate = self
player.enableRate = true       //变速
player.rate = 2                       //2倍速度播放
player.volume = 0.3              //音量

player.prepare()
player.play()

player.duration
player.currentTime

AVAudioPlayerDelegate
audioPlayer didFinish...

定时器

timer.invalidata( 
)            定时器不用了一定要停掉

####页面跳转

页面:UIViewController或它的子类
弹出新页面:已经弹出的页面.presentViewController(viewCtrl, animate: true, completion: nil)
消失:self.dismissView....
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • *7月8日上午 N:Block :跟一个函数块差不多,会对里面所有的内容的引用计数+1,想要解决就用__block...
    炙冰阅读 2,554评论 1 14
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,259评论 4 61
  • 代码创建UIWindow对象 Xcode7之后使用代码创建UIWindow对象: //创建UIWindow对象 s...
    云之君兮鹏阅读 1,383评论 0 2
  • 由于有时候为了省事将Ubuntu安装成中文版,而在终端中中文会显示乱码,因此需要将默认语言改为英文。用vi(或na...
    放风筝的小小马阅读 5,526评论 0 0
  • 说真的,我很喜欢知乎。 有人说,知乎就是故事会,只是逼格比俗套的都市言情戏要高。有人说,知乎就是一群好为人师的人在...
    你看得见我阅读 1,069评论 1 9