最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS實(shí)現(xiàn)微信搖一搖功能

 更新時(shí)間:2018年06月25日 14:59:37   作者:獅兄  
這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)微信搖一搖功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

一、描述

需要做一個(gè)界面,仿照微信搖一搖,獲取接口進(jìn)行簽到功能。
首先明確以下幾點(diǎn):

1、需要震動(dòng)。
2、需要聲音。(準(zhǔn)備好mp3音效)

二、這邊直接貼代碼

/ Created by 石雄偉 on 16/7/29.
// Copyright © 2016年 石雄偉. All rights reserved.
//

#import "SignBoardViewController.h"
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <CoreAudio/CoreAudioTypes.h>
@interface SignBoardViewController ()
{
}
@property (nonatomic,strong) AVAudioPlayer * audioPlayer;

@end

@implementation SignBoardViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  // Do any additional setup after loading the view.
  //設(shè)置導(dǎo)航
  [self makeNav];
}

#pragma mark 定制Nav
- (void)makeNav
{
  [self.navigationItem setTitle:@"每日簽到"];//改寫title
  //修改導(dǎo)航按鈕,并且修改響應(yīng)方法
  self.leftButton.frame = CGRectMake(0, 0, 13, 20);
  [self.leftButton setBackgroundImage:[UIImage imageNamed:@"NavBack"] forState:UIControlStateNormal];
  self.leftButton.layer.cornerRadius = 0;
  self.leftButton.layer.masksToBounds = NO;
  self.leftButton.layer.borderColor = [UIColor clearColor].CGColor;

  //添加點(diǎn)擊方法
  [self.leftButton addTarget:self action:@selector(navLeftClick) forControlEvents:UIControlEventTouchUpInside];

  //隱藏 右邊按鈕
  self.rightButton.hidden= YES;
}

#pragma mark nav左邊導(dǎo)航按鈕方法重寫,返回按鈕
- (void)navLeftClick
{
  [self dismissViewControllerAnimated:YES completion:^{
    nil;
  }];
}

#pragma mark -
#pragma mark 點(diǎn)擊
- (void)touchesBegan:(nonnull NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event

{
  NSLog(@"點(diǎn)擊,觸摸方法等");
  AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

}

#pragma mark -
#pragma mark 搖動(dòng)開始
- (void)motionBegan:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event

{

  NSLog(@"begin motion");

}

#pragma mark -
#pragma mark 搖動(dòng)結(jié)束
- (void)motionEnded:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event
{
  NSLog(@"end motion");
  if (motion ==UIEventSubtypeMotionShake )
  {
    //播放音效
    SystemSoundID  soundID; // shake_sound_male.mp3
    NSString *path = [[NSBundle mainBundle ] pathForResource:@"shake_sound_male" ofType:@"mp3"];
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &soundID);
    AudioServicesPlaySystemSound (soundID);
    //設(shè)置震動(dòng)
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
  }

}

#pragma mark -
#pragma mark 搖動(dòng)取消
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{

}

- (void)didReceiveMemoryWarning {
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  // Get the new view controller using [segue destinationViewController].
  // Pass the selected object to the new view controller.
}
*/

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 圖文講解如何解決App的iOS 7頂部狀態(tài)欄適配問題

    圖文講解如何解決App的iOS 7頂部狀態(tài)欄適配問題

    至今很多iOS App還要照顧到iOS 7進(jìn)行最低的版本適配,而iOS7開始status bar的實(shí)際屏幕占用情況與iOS 6等不盡相同,這里我們就來以圖文講解如何解決App的iOS 7頂部狀態(tài)欄適配問題
    2016-06-06
  • ios下OC與JS交互之WKWebView

    ios下OC與JS交互之WKWebView

    本篇文章主要介紹了ios下OC與JS交互之WKWebView,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-03-03
  • IOS筆記061之二維碼的生成和掃描

    IOS筆記061之二維碼的生成和掃描

    隨著移動(dòng)設(shè)備的普及為二維碼提供了一個(gè)很好應(yīng)用平臺(tái),無論是在商城購物還是美食城都離不開二維碼,本篇文章就給大家介紹IOS筆記061之二維碼的生成和掃描,感興趣的朋友可以過來一起學(xué)習(xí)啦,本文內(nèi)容講的很詳細(xì)
    2015-08-08
  • iOS狀態(tài)欄的顯示與隱藏的示例代碼

    iOS狀態(tài)欄的顯示與隱藏的示例代碼

    這篇文章主要介紹了iOS狀態(tài)欄的顯示與隱藏的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-07-07
  • 運(yùn)用iOS教你輕松制作音樂播放器

    運(yùn)用iOS教你輕松制作音樂播放器

    這篇文章主要教大家如何運(yùn)用iOS輕松制作音樂播放器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • iOS UIAlertController中UITextField添加晃動(dòng)效果與邊框顏色詳解

    iOS UIAlertController中UITextField添加晃動(dòng)效果與邊框顏色詳解

    這篇文章主要給大家介紹了關(guān)于iOS UIAlertController中UITextField添加晃動(dòng)效果與邊框顏色的相關(guān)資料,實(shí)現(xiàn)后的效果非常適合在開發(fā)中使用,文中給出了詳細(xì)的示例代碼,需要的朋友可以參考借鑒,下面隨著小編來一起看看吧。
    2017-10-10
  • iOS鍵盤自適應(yīng)彈出效果

    iOS鍵盤自適應(yīng)彈出效果

    這篇文章主要為大家詳細(xì)介紹了iOS鍵盤自適應(yīng)彈出效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • 將多個(gè)字符串高亮顯示之TTTAttributedLabel

    將多個(gè)字符串高亮顯示之TTTAttributedLabel

    本文介紹了將多個(gè)字符串高亮顯示之TTTAttributedLabel。在此需要對(duì)每個(gè)字符串進(jìn)行匹配,可以研究下kmp和bm算法,在這里應(yīng)用了oc自帶的NSRegularExpression 來進(jìn)行正則表達(dá)式匹配,算是比較簡單的方法,需要的朋友可以參考下
    2015-07-07
  • React Native學(xué)習(xí)教程之Modal控件自定義彈出View詳解

    React Native學(xué)習(xí)教程之Modal控件自定義彈出View詳解

    這篇文章主要給大家介紹了關(guān)于React Native學(xué)習(xí)教程之Modal控件自定義彈出View的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用React Native具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-10-10
  • IOS開發(fā)之JSON轉(zhuǎn)PLIST實(shí)例詳解

    IOS開發(fā)之JSON轉(zhuǎn)PLIST實(shí)例詳解

    這篇文章主要介紹了IOS開發(fā)之JSON轉(zhuǎn)PLIST實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2016-11-11

最新評(píng)論

探索| 台北市| 宁陵县| 江北区| 祥云县| 阿拉善盟| 大理市| 杨浦区| 东安县| 凌海市| 修武县| 福鼎市| 贞丰县| 南投市| 南宫市| 肥乡县| 潼关县| 旌德县| 东乡| 隆子县| 南昌市| 台东市| 东乡| 米易县| 凤阳县| 资中县| 云霄县| 丽江市| 安新县| 上杭县| 阆中市| 叶城县| 嘉荫县| 龙口市| 宜宾市| 鄯善县| 房产| 蒙阴县| 郎溪县| 祁门县| 苗栗县|