我用什么代码来确定用户iPhone铃声是打开还是关闭?
我正在制作的应用程序,在后台播放音乐,如果iphone铃声开关关闭,那么我希望音乐停止播放.
我的问题与此类似,但我想在swift和IOS8中得到答案......
码:
if iphoneRinger == On {
self.playmusic()
}
else {
self.stopmusic()
}
Run Code Online (Sandbox Code Playgroud) 我希望我的应用程序中有一个按钮,当按下它时,会弹出这个(见下图).我怎么做?我不想创建自定义共享extion,我只想要默认的一个?我用什么代码?所有在线教程都是客观的.请迅速给出答案.
到目前为止,这是我的代码,但是我得到一个错误,UIBarButtonItem不能为UIVIew提供什么?该操作是否连接到导航栏按钮项?
@IBAction func ActionButton(sender: UIBarButtonItem) {
let firstActivityItem = "Text you want"
let secondActivityItem : NSURL = NSURL(string: "http//:urlyouwant")!
// If you want to put an image
let image : UIImage = UIImage(named: "TALogo")!
let activityViewController : UIActivityViewController = UIActivityViewController(
activityItems: [firstActivityItem, secondActivityItem, image], applicationActivities: nil)
// This lines is for the popover you need to show in iPad
activityViewController.popoverPresentationController?.sourceView = (sender as! UIBarButtonItem)
// This line remove the arrow of the popover to show in iPad …Run Code Online (Sandbox Code Playgroud)