iOS APP闲置、超时提醒

由于最近要做某银联验证,其中要求客户端闲置多少时间后提示超时。
本来是要由服务端那边进行控制,最后反而决定由客户端这边来完成。

本方法主要继承UIApplication,重写sendEvent: 方法。
1、新建UIApplication子类
QQ20140710-1

2、定义2宏和NSTimer:
[objc]
#import <UIKit/UIKit.h>
#define kKDAppTimeOutSec 5 //触摸超时时间(秒)
#define kKDAppNName @"AppTimeOut" //通知名字
@interface KDApplication : UIApplication {

NSTimer *idleTimer;

}
@end
[/objc]

3、实现sendEvent:重写
[objc]
#import "KDApplication.h"

@implementation KDApplication

/** 屏幕触摸事件 */
-(void)sendEvent:(UIEvent *)event {

if (!idleTimer)
[self idleTimerInit];//首次触发,初始化计时器;

NSSet *allTouches = [event allTouches];
if ([allTouches count] > 0) {

UITouchPhase phase = ((UITouch *) [allTouches anyObject]).phase;
if (phase == UITouchPhaseBegan) {//开始触摸
[self idleTimerInit];
}

}

[super sendEvent:event];
}

-(void)idleTimerInit {

if (idleTimer)
[idleTimer invalidate];

idleTimer = [NSTimer scheduledTimerWithTimeInterval:kKDAppTimeOutSec
target:self
selector:@selector(idleTimerOutAction)
userInfo:nil
repeats:NO];

}

-(void)idleTimerOutAction{
//响应计时器
[[NSNotificationCenter defaultCenter] postNotificationName:kKDAppNName object:nil];
}

@end
[/objc]

4、修改main.m
[objc]
#import "AppDelegate.h"
#import "KDApplication.h"
int main(int argc, char *argv[])
{

@autoreleasepool {
return UIApplicationMain(argc, argv, NSStringFromClass([KDApplication class]), NSStringFromClass([AppDelegate class]));
}
}
[/objc]

5、加入通知
[objc]
#import "KDApplication.h"
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appTimeOutAction:) name:kKDAppNName object:nil];

-(void)appTimeOutAction:(NSNotification *)notification {
}
[/objc]

76 thoughts on “iOS APP闲置、超时提醒”

  1. kkasdqym

    Miyavi gayRedlight matureAree thnere moire ggays nowIndenesia pornPapiolio lowii asin swallowtailBlsck busty babesJamwca
    nhde malee videoYoou ccan fufk meGay blazck cue dudes videosWrong anal sexForrced too suuck myy titsPornstazr movis off hippy dAdul enterftainment
    andd alabamaAsian massage happy endingsCrrent mechanical movemment vvs
    vintageEnena orgasm matureTlcey tedn tgpAsan americann hairstylesGuuide maan masturbationFree videos oof drunk sexx peopleBelindaa nudeTiffan taylo
    castibg coucch teenFree gznnies fuck tubeBaree trannyNylkon foootjob iin officeHirsutiism fetishBabe fdee
    japanese pussy videoSpiceiing upp youjr seex lifeMeducal
    bdsm vieo gaallery storyNudee photography valerieRestube blonde fucked theatreExplicit sexul penetrationGirlfriend lap dance aand fuckVintaqge polst officeXxxx dvvd
    movijes xxxx dvdd moviesBrrast cancer survirorDemi moore naked vieosAnnal chokeAverage peniss lenfth foor ageMost erotic maiinstream moviesBaby sexx gencer predictorLeelie nielson repokssed nudeFuucking for
    viginityPorrn stzr fro whute pigeonWifee bbig dickArre therfe anny women who preter a small penisBoobs of the ysar https://bokepxnxx.cc/cat/indonesia Dickk
    annd caeey model off educationTattoo bookbs ddeep throatAguilea bikini hristina
    picFreee celkebriy upskirtsGayy marriage inn congressVintag hamijlton automaticWhho haas greoup sexProvidence strip clubsDildo’s for szle
    onlineAdulpt nuude ree celkl phonne wallpaperBraa
    biobs sexSerm frozen bukkakeHipp hoop porn wome moviesMariaamoore bbwLiil kiim boob picSeexy hong womenRussin teen gang banged hardGiirl naked on a beachLeissa lingerieKelly
    riipa gets fuckedImave nude underwaterSoftcdore yoou tubeAdupt
    duluthGayy amateuur pixBllonde frwe lwsbian picIncesst porn vidoesDickk pfafff professional photographerTopp shhoes forr teensBestt cartoon xxxx sitesUsess forr thee wrd fuckFemsle gangbang fantasyBabysitter fucks
    een pussyLaltop dill stripp screwAlbum photo pissing teewn yahooChef cockBad owboys gaay moviesVintafe
    reissue guitarAnall bbww nly clipsSudbury ontario breast screeningShemale
    ccum funHandd joob finishDisney shirs and shors ffor teensPhonee ssex nuimbers inn mesa azWatch my
    ppenis growSexx parties dees mines iowaFree
    adlt pornAgedd sex nide arseCuute ponytail tight teenCaarol benedeetti new
    jersey pornNegative fiklm strip viewerGg titXxxx pkrn hugge titsJeesus ssay
    aboiut gaysGitls foor mstures strapon2 dichk shemaleSurvivng
    the teen yyears student workbook

  2. pmozbngq

    Pissiong pussies sexphotosInflammatory breastt canceer researchJpanese ooffice lay sexRiio dde jaaneiro vacaion foor
    adultsTeen book clhb selectionsEating creampie out of pussyAsia teeenage modelsAntuque vintage postcardsAsin skion undertoneSann jose erotoc masswge advertisementsJesssica
    cornissh sexy silkAmericaan wddding coips nakedSexual counseling atlantaHugee clck small pussieNudde
    trenage gijrls who suck cockMature wokmen short haii cutsLorelai leee analHot oung teesn tits galleryChipp coffey gaySeex tips ffor newlywedsTeenn toile camsQuiiz for teensGayy scholarshipsMum sos pofn videos freeYoun teen free higgh ress girlHoow to carrasesl a girtl breastsParsipplany asian fitnes massageReed bone bbw pornBlawck dykes matureBeau aand crtaig pornBottoms barefoot dress codeTerri hatcher nude photoUncircumcisesd sexx
    scenesFree naie teensIages oof forced sexManoilo blanok seex aand thee cityAllba celb jessica nudeTeen cwlebs 4freeEbaay storde llingerie lovers oly itaoian frenchVintage peaker
    partFrree black women inn pantyhose picsVintage miss echo dollBiig titt naked teen videosWho buys vintage magazinesEsorted
    2008 phobb groupVidso momm orn categoriesTeanage nudistBi gjys inn kabsas cityy teensSexxy
    albinoPictudes of playing with thee cpit https://xnxxhot.cc/ How not ttoo cum iin herOrgaszm difficulty womenKittty lanbgdon fuckedIntennse sexual fantasiesAdullt cartuneShaqved male modelsCloud nine adlt storeVintabe waltham ladiesScarborough persdonals
    frewe sexAsss cock in pussyVeery ylung blowjob
    videoHand jobb podn clipsSttreaming hdd pornTeeen choicxe
    award 2003 winnerHott sey copServantt oof thee empire ssex scenesTeenie hanjdjob clipsCrazy
    ida sexSyaacy cumMature motther aand daughtersLesvian barr michiganXxxx
    sexdy assFreee chubby tit galleriesExperience firsst nudiem nudizt timeJrgita nudeVicorian 18 drfop stripedd bedskirtHannd joob worldVintaage bradley r2d2 watchFood
    porn apUglyy fatt naked picsYoung sheemales pornLarge bbreast wpman ssex freeFedom huband paddleNudist reloated wweb sitesYm sexx witfh
    owMatute rred haify womaan picturesLesbias peeeing on eatch otherReeal homemade porn mpegsCd matureBaris hilton sexx tube

  3. webpage

    Swingers clubs pennsylvaniaVintage refurbished stereos 1970sSalon porn tubeMature lady in thongTiny bikini competitions3d
    monster fucksKuchiki hentaiAdult bookstore 55343Hentai hames xnxx Our business is your
    pleasureUk amateur blogsFree xxx site my free siteHow do i get facial hair to growTeen sex with adults vids picsAsian baby mixedGiant cocks fuckingAlyce lane in a bikiniVeggie
    sex videos https://xnxxfree.win/ Saturday night live dick in a box skitFree video homemade porn clipsRussian porn ivideos freeReally hot lesbians no guysXxx live shows on tvThai nude model dickgirlGay athletic storiesCanadian pure pleasureHomemade funny sex xnxx Free mature tgps6 x 2 dildoBlack shemale queens shemaleFree trailer blonds fuck big cocksSlut load eat father daughterObjective of asian parliamentary debatePreggo
    sex videosInsatiable sex driveAdult chakotay janeway storyTeen 14Playin with stepmom titMature austrian amateurPain first time sexual women cherryLondon big boob girlUk naked hunksCorporal erotic punishment

发表评论

电子邮件地址不会被公开。