国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語(yǔ)言|JavaScript|易語(yǔ)言|vb.net|

服務(wù)器之家 - 編程語(yǔ)言 - Swift - swift在IOS應(yīng)用圖標(biāo)上添加提醒個(gè)數(shù)的方法

swift在IOS應(yīng)用圖標(biāo)上添加提醒個(gè)數(shù)的方法

2020-12-29 16:31JackWang-CUMT Swift

本文是通過(guò)swift語(yǔ)言實(shí)現(xiàn)在應(yīng)用圖標(biāo)右上角添加消息個(gè)數(shù)提醒的功能,非常不錯(cuò),具有參考借鑒價(jià)值,感興趣的朋友一起看下吧

應(yīng)用圖標(biāo)右上角添加消息數(shù)提醒,可以很方便的告知用戶該應(yīng)用中有無(wú)新消息需要處理。下面用xcode 7.3.1來(lái)簡(jiǎn)要說(shuō)明一下如何用swift語(yǔ)言進(jìn)行此功能的實(shí)現(xiàn)。

1、修改 AppDelegate.swift

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// AppDelegate.swift
// RainbowDemo
//
// Created by Jackwang on 16/8/17.
// Copyright © 2016年 Jackwang . All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//使用UILocalNotification除了可以實(shí)現(xiàn)本地消息的推送功能(可以設(shè)置推送內(nèi)容,推送時(shí)間,提示音),
//還可以設(shè)置應(yīng)用程序右上角的提醒個(gè)數(shù)。
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound],
categories: nil)
application.registerUserNotificationSettings(settings)
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}

2 修改在ViewController.swift

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// ViewController.swift
// RainbowDemo
//
// Created by jackwang on 16/8/17.
// Copyright © 2016年 jackwang. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//發(fā)送通知消息
scheduleNotification();
}
//發(fā)送通知消息
func scheduleNotification(){
//清除所有本地推送
UIApplication.sharedApplication().cancelAllLocalNotifications()
//創(chuàng)建UILocalNotification來(lái)進(jìn)行本地消息通知
let localNotification = UILocalNotification()
//設(shè)置應(yīng)用程序右上角的提醒個(gè)數(shù)
localNotification.applicationIconBadgeNumber = 8;
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

3 編譯運(yùn)行

第一次會(huì)彈出詢問(wèn)是否允許推送消息,確認(rèn)后,第二次運(yùn)行該app后,會(huì)在圖標(biāo)右上角標(biāo)注消息數(shù),如下圖所示:

swift在IOS應(yīng)用圖標(biāo)上添加提醒個(gè)數(shù)的方法

修改APP的顯示名稱,可以單擊info.plist,然后修改器Bundle name,如下圖所示:

swift在IOS應(yīng)用圖標(biāo)上添加提醒個(gè)數(shù)的方法

以上所述是小編給大家介紹的swift在IOS應(yīng)用圖標(biāo)上添加提醒個(gè)數(shù)的方法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)服務(wù)器之家網(wǎng)站的支持!

原文鏈接:http://www.cnblogs.com/isaboy/archive/2016/08/18/swift_ios_app_UILocalNotification_msg.html

延伸 · 閱讀

精彩推薦
  • SwiftSwift實(shí)現(xiàn)多個(gè)TableView側(cè)滑與切換效果

    Swift實(shí)現(xiàn)多個(gè)TableView側(cè)滑與切換效果

    這篇文章主要為大家詳細(xì)介紹了Swift實(shí)現(xiàn)多個(gè)TableView側(cè)滑與切換效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下...

    乞力馬扎羅的雪雪5822021-01-08
  • SwiftSwift中轉(zhuǎn)義閉包示例詳解

    Swift中轉(zhuǎn)義閉包示例詳解

    在Swift 中的閉包類似于結(jié)構(gòu)塊,并可以在任何地方調(diào)用,下面這篇文章主要給大家介紹了關(guān)于Swift中轉(zhuǎn)義閉包的相關(guān)資料,需要的朋友可以參考下...

    小小小_小朋友11412021-12-26
  • SwiftSwift教程之基礎(chǔ)數(shù)據(jù)類型詳解

    Swift教程之基礎(chǔ)數(shù)據(jù)類型詳解

    這篇文章主要介紹了Swift教程之基礎(chǔ)數(shù)據(jù)類型詳解,本文詳細(xì)講解了Swift中的基本數(shù)據(jù)類型和基本語(yǔ)法,例如常量和變量、注釋、分號(hào)、整數(shù)、數(shù)值類型轉(zhuǎn)換等...

    Swift教程網(wǎng)5162020-12-18
  • SwiftSwift能代替Objective-C嗎?

    Swift能代替Objective-C嗎?

    這是我在網(wǎng)上上看到的答案,復(fù)制粘貼過(guò)來(lái)和大家分享一下,因?yàn)槲液秃芏嗳艘粯雍荜P(guān)心Swift的出現(xiàn)對(duì)Mac開發(fā)的影響和對(duì)Objective-C的影響。...

    Swift教程網(wǎng)4412020-12-16
  • Swiftswift where與匹配模式的實(shí)例詳解

    swift where與匹配模式的實(shí)例詳解

    這篇文章主要介紹了swift where與匹配模式的實(shí)例詳解的相關(guān)資料,這里附有簡(jiǎn)單的示例代碼,講的比較清楚,需要的朋友可以參考下...

    追到夢(mèng)的魔術(shù)師14382021-01-06
  • Swiftmac git xcrun error active developer path 錯(cuò)誤

    mac git xcrun error active developer path 錯(cuò)誤

    本文主要是講訴了如何解決在mac下使用git;xcode4.6的環(huán)境時(shí),出現(xiàn)了錯(cuò)誤(mac git xcrun error active developer path)的解決辦法,希望對(duì)大家有所幫助...

    Swift教程網(wǎng)2232020-12-16
  • SwiftSwift的74個(gè)常用內(nèi)置函數(shù)介紹

    Swift的74個(gè)常用內(nèi)置函數(shù)介紹

    這篇文章主要介紹了Swift的74個(gè)常用內(nèi)置函數(shù)介紹,這篇文章列舉出了所有的Swift庫(kù)函數(shù),內(nèi)置函數(shù)是指無(wú)需引入任何模塊即可以直接使用的函數(shù),需要的朋友可...

    Swift教程網(wǎng)5802020-12-19
  • SwiftSwift使用CollectionView實(shí)現(xiàn)廣告欄滑動(dòng)效果

    Swift使用CollectionView實(shí)現(xiàn)廣告欄滑動(dòng)效果

    這篇文章主要為大家詳細(xì)介紹了Swift使用CollectionView實(shí)現(xiàn)廣告欄滑動(dòng)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下...

    Stevin的技術(shù)博客12372021-01-13
主站蜘蛛池模板: 国产欧美精品一区二区三区 | 男人午夜视频在线观看 | 欧美精品一区二区三区在线 | 国产精品女同一区二区免费站 | 国产综合精品 | 国产精品久久久久久久久久久久久 | 欧美色综合天天久久综合精品 | 日韩视频在线观看 | 欧洲精品久久久久毛片完整版 | 日韩有码在线播放 | 中文字幕一区在线观看视频 | 黄片毛片毛片毛片 | 国产精品无码久久久久 | 91国产精品 | 亚洲免费观看在线视频 | 91精品国产综合久久福利软件 | 国产一区中文字幕 | 国产激情精品视频 | 日本不卡一区二区三区 | 精品一区二区三区视频 | 欧美黑人狂躁日本寡妇 | 久草视频在线播放 | 在线播放一区二区三区 | 国产激情偷乱视频一区二区三区 | 久久久久成人精品免费播放动漫 | 久久91精品 | 久久综合激情 | 中文字幕亚洲国产 | 精品一二区 | 天堂99x99es久久精品免费 | 国产亚洲视频在线 | a级毛片免费高清视频 | 国产99久久 | 成人福利免费在线观看 | 色婷婷av一区二区三区大白胸 | 免费观看污污视频 | 亚洲成人影音 | 国产成人精品免费 | 人人做人人澡人人爽欧美 | 在线色综合 | 欧美成人性生活 |