IOS代码笔记之左右滑动效果_IOS

本文实例为大家分享了ios实现左右滑动操作代码,供大家参考,具体内容如下

一、效果图

 

二、代码
RootViewController.m

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

  self.title=@"可以向左(右)滑动";

  //向右滑动
  UISwipeGestureRecognizer *recognizerLeft;
  recognizerLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFromLeft:)];
  [recognizerLeft setDirection:(UISwipeGestureRecognizerDirectionLeft)];
  [self.view addGestureRecognizer:recognizerLeft];

  //向左滑动
  UISwipeGestureRecognizer *recognizerRight;
  recognizerRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFromRight:)];
  [recognizerRight setDirection:(UISwipeGestureRecognizerDirectionRight)];
  [self.view addGestureRecognizer:recognizerRight];

}
#pragma -mark -手势滑动
//向左滑动
-(void)handleSwipeFromLeft:(UISwipeGestureRecognizer *)recognizer {

  NSLog(@"-------进入向左手势滑动姿势-------------");
  if (recognizer.direction==UISwipeGestureRecognizerDirectionLeft) {

    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"进入向左手势滑动姿势" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];

  }
}
//向右滑动
-(void)handleSwipeFromRight:(UISwipeGestureRecognizer *)recognizer {

  NSLog(@"-------进入向右手势滑动姿势-------------");
  if (recognizer.direction==UISwipeGestureRecognizerDirectionRight) {

    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"进入向右手势滑动姿势" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];

  }
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索iOS滑动
ios左右滑动
h5左右滑动效果代码、jq左右滑动效果代码、jquery左右滑动效果、移动端左右滑动效果、jq左右滑动效果,以便于您获取更多的相关知识。

时间: 2024-08-03 10:00:43

IOS代码笔记之左右滑动效果_IOS的相关文章

IOS代码笔记之文字走马灯效果_IOS

本文实例为大家分享了IOS文字走马灯效果具体实现代码,供大家参考,具体内容如下 一.效果图 二.工程图  三.代码RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController : UIViewController @end RootViewController.m #import "RootViewController.h" #import "UXLabel.h" @

IOS代码笔记之下拉菜单效果_IOS

本文实例为大家分享了ios下拉菜单的具体代码,供大家参考,具体内容如下 一.效果图 二.工程图 三.代码 RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController : UIViewController @end   RootViewController.m #import "RootViewController.h" #import "NIDropDown.h"

IOS代码笔记之网络嗅探功能_IOS

本文实例为大家分享了IOS网络嗅探工具,供大家参考,具体内容如下 一.效果图    二.工程图   三.代码AppDelegate.h #import <UIKit/UIKit.h> #import "Reachability.h" @interface AppDelegate : UIResponder <UIApplicationDelegate> { Reachability *reachability; BOOL WarningViaWWAN; } @p

IOS代码笔记UIView的placeholder的效果_IOS

本文实例为大家分享了IOS占位符效果,供大家参考,具体内容如下 一.效果图   二.工程图   三.代码RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController : UIViewController <UITextViewDelegate> { UITextView *psTextView; UILabel *pslabel; } @end RootViewController.m #imp

用iOS代码获取APP启动页图片_IOS

用代码获取APP启动页图片  // // AppleSystemService.swift // Swift-Animations // // Created by YouXianMing on 16/8/11. // Copyright 2016年 YouXianMing. All rights reserved. // import UIKit class AppleSystemService : NSObject { /** Get the lauch image. - returns:

IOS代码笔记之仿电子书书架效果_IOS

本文实例为大家分享了IOS书架效果的具体实现代码,供大家参考,具体内容如下 一.效果图   二.工程图  三.代码RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController : UIViewController <UITableViewDataSource,UITableViewDelegate> { NSMutableArray * dataArray; UITableView * myTa

iOS如何用100行代码实现简单的抽屉效果_IOS

前言 iOS中抽屉效果的简单实现现在很多应用中都使用到了,网上也有很多了例子,本文主要是通过简单的一些代码来实现的,有需要的可以一起学习学习. 下面是效果图 示例代码如下 #import <UIKit/UIKit.h> @interface MainViewController : UIViewController + (instancetype)mainViewControllerWithLeftViewController:(UIViewController *)leftViewContr

详解IOS中如何实现瀑布流效果_IOS

首先是效果演示 特点:可以自由设置瀑布流的总列数(效果演示为2列) 虽然iphone手机的系统相册没有使用这种布局效果,瀑布流依然是一种很常见的布局方式!!!下面来详细介绍如何实现这种布局. 首先使用的类是UICollectionView 我们要做的是自定义UICollectionViewCell和UICollectionViewLayout      1.自定义UICollectionViewCell类,只需要一个UIImageView即可,frame占满整个cell.      2.重点是自

iOS利用UIScrollView实现无限滚动效果_IOS

前言 众所周知UIScrollView 的无限滚动主要应用在图片轮播器.欢迎界面等场景.它的原理是在要显示的图片前后各加一张图片即在第一张图片之前放最后一张图片,在最后一张图片之后放第一张图片,然后在滚动到边缘的时候,巧妙的过渡一下就可以"瞒天过海","以假乱真"的造成无限滚动的假象.网络上有很多只用三张或两张图片实现的方法,效率比这个方法高,但实现起来稍微麻烦一点,有兴趣的可以去深入研究. 实现步骤       1.根据需求准备几张图片,在网上找了5张图片,分别命