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

IOS中MMDrawerController第三方抽屜效果的基本使用示例

 更新時(shí)間:2017年02月13日 11:14:06   作者:賣萌就挨打  
這篇文章主要介紹了IOS中MMDrawerController第三方抽屜效果的基本使用示例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。

因?yàn)閯傞_年,所以最近公司比較閑,看到以前并不是我接手的項(xiàng)目中有這種抽屜效果的控制器,比較感興趣,便對(duì)MMDrawerController研究起來。也方便自己忘記之后查閱,另外也希望對(duì)大家有所幫助(PS:以前都是上面一個(gè)導(dǎo)航欄,下面一個(gè)tabbar的項(xiàng)目居多,所以對(duì)這種抽屜控制器不是很了解).

1.首先,到GitHub上把MMDrawerController下下來,然后倒入到項(xiàng)目中。當(dāng)然你用cocoapods倒入也行??茨阈那閱hO(∩_∩)O


2.接下來就在appdelegate中擼我們的代碼了。先倒入各個(gè)控制器哈。

#import"MMDrawerController.h"
#import"rightViewController.h"
#import"centerViewController.h"
#import"leftViewController.h"
#import"MainNavViewController.h"

然后就是在didFinishLaunching中設(shè)置相關(guān)的控制了,其實(shí)跟平時(shí)項(xiàng)目的區(qū)別就是多了一個(gè)抽屜控制器。

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
self.window= [[UIWindowalloc]initWithFrame:[UIScreenmainScreen].bounds];
//左中右三個(gè)控制器
rightViewController*rightVc = [[rightViewControlleralloc]init];
leftViewController*leftVc = [[leftViewControlleralloc]init];
centerViewController*centerVc = [[centerViewControlleralloc]init];
//導(dǎo)航控制器
MainNavViewController*rightNavVc = [[MainNavViewControlleralloc]initWithRootViewController:rightVc];
MainNavViewController*leftNavVc = [[MainNavViewControlleralloc]initWithRootViewController:leftVc];
MainNavViewController*centerNavVc = [[MainNavViewControlleralloc]initWithRootViewController:centerVc];
//抽屜控制器
self.mmDrawerController= [[MMDrawerControlleralloc]initWithCenterViewController:centerNavVcleftDrawerViewController:leftNavVcrightDrawerViewController:rightNavVc];
//  關(guān)閉模式手勢(shì)
self.mmDrawerController.closeDrawerGestureModeMask = MMCloseDrawerGestureModeAll;
//  打開模式手勢(shì)
self.mmDrawerController.openDrawerGestureModeMask = MMOpenDrawerGestureModeAll;
//  抽屜控制器的最長寬度
self.mmDrawerController.maximumLeftDrawerWidth = 200;
[self.windowmakeKeyAndVisible];
self.window.rootViewController=self.mmDrawerController;
returnYES;
}

其實(shí)在這里就已經(jīng)可以實(shí)現(xiàn)抽屜控制器的基本效果的了。但是要如下圖的效果還得加一丟丟代碼。


然后我們?cè)赾enter控制器導(dǎo)航欄的leftBarButton上自定義一個(gè)button,添加點(diǎn)擊事件等等,這應(yīng)該不難哈。記得要導(dǎo)入相關(guān)的類。

#import "UIViewController+MMDrawerController.h"
- (void)viewDidLoad {
  [super viewDidLoad];
  // Do any additional setup after loading the view.
  self.title = @"Demo";
  self.view.backgroundColor = [UIColor greenColor];
  //UIBarButtonItem的自定義的分類方法
  self.navigationItem.leftBarButtonItem = [UIBarButtonItem initWithTarget:self action:@selector(leftBtnClick) image:@"菜單 (1)" hightImage:@"菜單"];
}

-(void)leftBtnClick{
//  將左邊的控制器打開
  [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
}

下面就是left控制器的代碼哈,就是在view上添加了一個(gè)tableView。

#import "leftViewController.h"
#import "pushViewController.h"
#import "UIViewController+MMDrawerController.h"
#import "MainNavViewController.h"

@interface leftViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation leftViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor blueColor];

  UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
  tableView.delegate = self;
  tableView.dataSource = self;
  [self.view addSubview:tableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

  if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
  }

  cell.detailTextLabel.text = [NSString stringWithFormat:@"%zd",indexPath.row];

  return cell;
}

點(diǎn)擊cell跳轉(zhuǎn)控制器

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  pushViewController *pushVc = [[pushViewController alloc] init];
  pushVc.title = [NSString stringWithFormat:@"%zd",indexPath.row];
  //取到center控制器  
  MainNavViewController *mainNavVc = (MainNavViewController *)self.mm_drawerController.centerViewController;
  [mainNavVc pushViewController:pushVc animated:YES];
  //關(guān)閉了控制器之后記得將模式設(shè)置為None
  [self.mm_drawerController closeDrawerAnimated:YES completion:^(BOOL finished) {
    [self.mm_drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeNone];
  }];

}

最后記得在center控制器的viewDidAppear中打開滑動(dòng)的手勢(shì)

-(void)viewDidAppear:(BOOL)animated{
  [super viewDidAppear:animated];

  [self.mm_drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
}

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

相關(guān)文章

  • iOS實(shí)現(xiàn)百度地圖定位簽到功能

    iOS實(shí)現(xiàn)百度地圖定位簽到功能

    這篇文章主要給大家介紹了iOS實(shí)現(xiàn)百度地圖定位簽到功能的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-01-01
  • iOS13即將到來,iOS推送DeviceToken適配方案詳解

    iOS13即將到來,iOS推送DeviceToken適配方案詳解

    這篇文章主要介紹了iOS13即將到來,iOS推送DeviceToken適配方案詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • iOS 10自定義相機(jī)功能

    iOS 10自定義相機(jī)功能

    這篇文章主要為大家詳細(xì)介紹了iOS 10自定義相機(jī)功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-04-04
  • iOS導(dǎo)航欄對(duì)控制器view的影響詳解

    iOS導(dǎo)航欄對(duì)控制器view的影響詳解

    這篇文章主要給大家介紹了關(guān)于iOS導(dǎo)航欄對(duì)控制器view的影響的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)各位iOS開發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • IOS身份證識(shí)別(OCR源碼)詳解及實(shí)例代碼

    IOS身份證識(shí)別(OCR源碼)詳解及實(shí)例代碼

    這篇文章主要介紹了IOS身份證識(shí)別(OCR源碼)詳解及實(shí)例的相關(guān)資料,需要的朋友可以參考下
    2017-03-03
  • 支付寶支付開發(fā)IOS圖文教程案例

    支付寶支付開發(fā)IOS圖文教程案例

    這篇文章主要介紹了支付寶支付開發(fā)IOS案例的相關(guān)資料,需要的朋友可以參考下
    2016-04-04
  • iOS 驗(yàn)證碼按鈕倒計(jì)時(shí)功能

    iOS 驗(yàn)證碼按鈕倒計(jì)時(shí)功能

    在app注冊(cè)或者登錄需要驗(yàn)證碼的地方、為了避免短時(shí)間內(nèi)刷驗(yàn)證碼、往往會(huì)加上一層驗(yàn)證當(dāng)?shù)褂?jì)時(shí)結(jié)束后、可以重新獲取,關(guān)于ios 驗(yàn)證碼按鈕倒計(jì)時(shí)功能大家可以參考下本文
    2017-07-07
  • iOS中視頻播放器的簡單封裝詳解

    iOS中視頻播放器的簡單封裝詳解

    要實(shí)現(xiàn)封裝視頻播放器,首先需要實(shí)現(xiàn)視頻播放器,然后再去考慮怎樣封裝可以讓以后自己使用起來方便快捷。iOS9之前可以使用MediaPlayer來進(jìn)行視頻的播放,iOS9之后系統(tǒng)推薦使用AVFoundation框架實(shí)現(xiàn)視頻的播放。下面通過本文來看看詳細(xì)的介紹吧。
    2016-10-10
  • IOS 靜態(tài)庫打包流程簡化詳細(xì)介紹

    IOS 靜態(tài)庫打包流程簡化詳細(xì)介紹

    這篇文章主要介紹了IOS 靜態(tài)庫打包流程簡化詳細(xì)介紹的相關(guān)資料,開發(fā)好的靜態(tài)庫后需要手動(dòng)的合并.a文件,然后再拷貝相關(guān)的頭文件,接著把靜態(tài)庫和頭文件放在同一個(gè)文件里面打包發(fā)送給SDK的使用者,這里簡化下流程,需要的朋友可以參考下
    2016-12-12
  • iOS身份證號(hào)碼識(shí)別示例

    iOS身份證號(hào)碼識(shí)別示例

    本篇文章主要介紹了iOS身份證號(hào)碼識(shí)別示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-02-02

最新評(píng)論

沽源县| 自贡市| 周宁县| 大新县| 青河县| 九寨沟县| 清河县| 嵊泗县| 常熟市| 邯郸市| 且末县| 虞城县| 仪陇县| 安多县| 惠东县| 民和| 道孚县| 什邡市| 鹰潭市| 涿鹿县| 修武县| 阿勒泰市| 天祝| 翁牛特旗| 宝坻区| 清流县| 岑巩县| 平阳县| 永川市| 星子县| 林口县| 荆州市| 田东县| 曲周县| 元氏县| 永靖县| 石城县| 西乌珠穆沁旗| 娄底市| 商南县| 无为县|