欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

IOS如何實現(xiàn)手機(jī)震動的提示功能-創(chuàng)新互聯(lián)

小編給大家分享一下IOS如何實現(xiàn)手機(jī)震動的提示功能,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

創(chuàng)新互聯(lián)是一家以網(wǎng)站設(shè)計,開發(fā)核心業(yè)務(wù)的專業(yè)網(wǎng)站建設(shè)公司,創(chuàng)新互聯(lián)為客戶提供:軟文發(fā)稿、創(chuàng)新網(wǎng)站解決方案。我們的目標(biāo)是提高客戶網(wǎng)站項目的專業(yè)度,以創(chuàng)新和互聯(lián)的思維增加用戶體驗并有效提高潛在客戶。

IOS開發(fā)實現(xiàn)手機(jī)震動的提示實例代碼

我們都知道手機(jī)有震動功能,其實呢,這個功能實現(xiàn)起來特別的簡單,我們只需要用到幾個函數(shù)就可以了: 

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event

還有就是通過canBecomeFirstResponder:設(shè)置一個第一響應(yīng)者為label,然后搖動手機(jī)兩下,看看效果如下:

IOS如何實現(xiàn)手機(jī)震動的提示功能

代碼如下:

HHLAppDelegate.h

#import <UIKit/UIKit.h> 
 
@class HHLViewController; 
 
@interface HHLAppDelegate : UIResponder <UIApplicationDelegate> 
 
@property (strong, nonatomic) UIWindow *window; 
 
@property (strong, nonatomic) HHLViewController *viewController; 
 
@end

HHLAppDelegate.m

#import "HHLAppDelegate.h" 
 
#import "HHLViewController.h" 
 
@implementation HHLAppDelegate 
 
- (void)dealloc 
{ 
  [_window release]; 
  [_viewController release]; 
  [super dealloc]; 
} 
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
  self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 
  // Override point for customization after application launch. 
  self.viewController = [[[HHLViewController alloc] initWithNibName:@"HHLViewController" bundle:nil] autorelease]; 
  self.window.rootViewController = self.viewController; 
  [self.window makeKeyAndVisible]; 
  return YES; 
} 
 
- (void)applicationWillResignActive:(UIApplication *)application 
{ 
  // 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. 
} 
 
- (void)applicationDidEnterBackground:(UIApplication *)application 
{ 
  // 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. 
} 
 
- (void)applicationWillEnterForeground:(UIApplication *)application 
{ 
  // 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. 
} 
 
- (void)applicationDidBecomeActive:(UIApplication *)application 
{ 
  // 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. 
} 
 
- (void)applicationWillTerminate:(UIApplication *)application 
{ 
  // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
} 
 
@end

HHLViewController.h

#import <UIKit/UIKit.h> 
 
@interface HHLViewController : UIViewController 
 
@end 
 
 
@interface LabelForMotion : UILabel 
 
@end

HHLViewController.m

#import "HHLViewController.h" 
 
@interface HHLViewController () 
 
@end 
 
 
 
@implementation LabelForMotion 
 
- (BOOL)canBecomeFirstResponder 
{ 
  return YES; 
} 
 
@end 
@implementation HHLViewController 
 
- (void)viewDidLoad 
{ 
  [super viewDidLoad]; 
  LabelForMotion *label = [[[LabelForMotion alloc]init]autorelease]; 
  label.frame = self.view.bounds; 
  label.autoresizingMask =UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; 
  label.textAlignment = NSTextAlignmentCenter; 
   
  label.text = @"Shake me"; 
  [self.view addSubview:label]; 
  //將標(biāo)簽設(shè)置為第一響應(yīng)者 
  [label becomeFirstResponder]; 
  [label release]; 
} 
 
 
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event 
{ 
  NSLog(@"motionBegan"); 
} 
 
//震動結(jié)束時調(diào)用的方法 
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event 
{ 
  NSLog(@"motionEnded"); 
  UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"地震了" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil nil]; 
  [alert show]; 
  [alert release]; 
   
} 
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event 
{ 
  NSLog(@"motionCancelled"); 
} 
 
 
- (void)didReceiveMemoryWarning 
{ 
  [super didReceiveMemoryWarning]; 
  // Dispose of any resources that can be recreated. 
} 
 
@end

其實更簡單的沒有必要搞一個類繼承自UIlabel,可以直接定義一個UIlabel的對象就行了。

以上是“IOS如何實現(xiàn)手機(jī)震動的提示功能”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司行業(yè)資訊頻道!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站chinadenli.net,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

網(wǎng)頁題目:IOS如何實現(xiàn)手機(jī)震動的提示功能-創(chuàng)新互聯(lián)
轉(zhuǎn)載來源:http://chinadenli.net/article34/epspe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)軟件開發(fā)、移動網(wǎng)站建設(shè)、做網(wǎng)站、定制網(wǎng)站、微信公眾號

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營
中文字幕有码视频熟女| 在线精品首页中文字幕亚洲| 日本高清二区视频久二区| 午夜精品黄片在线播放| 91偷拍裸体一区二区三区| 亚洲一区二区欧美激情| 中文字幕精品一区二区三| 国内精品一区二区欧美| 中文字幕熟女人妻视频| 很黄很污在线免费观看| 亚洲精品国产精品日韩| 欧美黑人精品一区二区在线| 国产成人免费激情视频| 日本精品最新字幕视频播放| 国产免费人成视频尤物| 九九热精品视频免费在线播放| 麻豆91成人国产在线观看| 日本不卡在线视频你懂的| 亚洲综合天堂一二三区| 成年女人下边潮喷毛片免费| 日韩成人动画在线观看| 妻子的新妈妈中文字幕| 中文字幕亚洲视频一区二区| 久久精品a毛片看国产成人| 99久久国产精品亚洲| 欧美亚洲91在线视频| 欧美日韩中国性生活视频| 丝袜av一区二区三区四区五区| 欧美老太太性生活大片| 国产福利一区二区久久| 久久一区内射污污内射亚洲| 日韩人妻有码一区二区| 一级片二级片欧美日韩| 欧美成人欧美一级乱黄| 人妻精品一区二区三区视频免精| 我想看亚洲一级黄色录像| 久久精品欧美一区二区三不卡| 亚洲欧美日韩中文字幕二欧美 | 开心久久综合激情五月天| 黑人巨大精品欧美一区二区区| 欧美又黑又粗大又硬又爽|