在一些涉及個人隱私的場景下,尤其是當移動裝置包含太多私密資訊時,為使用者的安全考慮是有必要的。
桌面版的qq在很多年前就考慮到使用者離開電腦後隱私洩露的危險,提供了「離開電腦自動鎖定」或者「閒置鎖定」等類似功能,具體我也忘了。
而在iphone版的qq上,也提供了手勢鎖的功能。如下圖:
具體的**實現如下:
[cpp]view plain
copy
//// viewcontroller.m
// gesturelock
//// created by jason lee on 12-9-26.
//#import "viewcontroller.h"
#define lock_point_tag 1000
@inte***ce viewcontroller ()
@property (nonatomic, strong) uiimageview *imageview;
@property (nonatomic, assign) cgpoint linestartpoint;
@property (nonatomic, assign) cgpoint lineendpoint;
@property (nonatomic, strong) nsmutablearray *buttonarray;
@property (nonatomic, strong) nsmutablearray *selectedbuttons;
@property (nonatomic, assign) bool
drawflag;
@property (nonatomic, strong) uiimage *pointimage;
@property (nonatomic, strong) uiimage *selectedimage;
@end
@implementation viewcontroller
- (void
)dealloc
- (void
)viewdidload
- (void
)didreceivememorywarning
#pragma mark - trace touch point
- (void
)touchesbegan:(nsset *)touches withevent:(uievent *)event
[self.selectedbuttons addobject:btn];
[btn setimage:self.selectedimage forstate:uicontrolstatenormal];
} }
} }
- (void
)touchesmoved:(nsset *)touches withevent:(uievent *)event
} if(!btncontained)
} }
self.imageview.image = [self drawunlockline];
} }
- (void
)touchesended:(nsset *)touches withevent:(uievent *)event
#pragma mark - create lock points
- (void
)createlockpoints
; [self.imageview addsubview:btn];
btn.userinteractionenabled = no;
btn.tag = lock_point_tag + i * 3 + j;
if(!self.buttonarray)
[self.buttonarray addobject:btn];
} }
} #pragma mark - draw line
- (uiimage *)drawunlockline
cgcontextaddlinetopoint(context, self.lineendpoint.x, self.lineendpoint.y);
cgcontextstrokepath(context);
image = uigraphicsgetimagefromcurrentimagecontext();
uigraphicsendimagecontext();
return
image;
} #pragma mark -
- (void
)outputselectedbuttons
} @end
jason lee @ hangzhou
微博:@思禽飲霜
在iOS上增加手勢鎖屏 解鎖功能
在一些涉及個人隱私的場景下,尤其是當移動裝置包含太多私密資訊時,為使用者的安全考慮是有必要的。桌面版的qq在很多年前就考慮到使用者離開電腦後隱私洩露的危險,提供了 離開電腦自動鎖定 或者 閒置鎖定 等類似功能,具體我也忘了。而在iphone版的qq上,也提供了手勢鎖的功能。如下圖 具體的 實現如下 ...
iOS開發之應用內檢測手機鎖屏,解鎖狀態
1.程式在前台,這種比較簡單。直接使用darwin層的通知就可以了 import staticvoidscreenlockstatechanged cfnotificationcenterrefcenter,void observer,cfstringrefname,constvoid object...
iOS開發 檢測程式在前台和後台鎖屏解鎖的狀態
1 程式在前台判斷是否鎖屏或解鎖。判斷方法 直接使用darwin層的通知就可以。import define notificationlock cfstr define notificationchange cfstr define notificationpwdui cfstr static voi...