当前位置: 首页 > news >正文

做网站交接需要哪些权限广州疫情升级

做网站交接需要哪些权限,广州疫情升级,科技网站制作公司,手机app界面设计软件效果图 原理 就是设置collectionView调整顺序的代理方法,这里要注意一点 调整过代理方法之后,一定要修改数据源,否则导致错乱。 还有就是在collectionView上面添加一个长按手势,在长按手势的不同阶段,调用collectionV…

效果图

请添加图片描述

原理

就是设置collectionView调整顺序的代理方法,这里要注意一点
调整过代理方法之后,一定要修改数据源,否则导致错乱。
还有就是在collectionView上面添加一个长按手势,在长按手势的不同阶段,调用collectionView 调整顺序的系统方法 beginInteractiveMovementForItemAtIndexPath
等等

代码

//
//  ViewController.m
//  LBEditCollectionCellOrder
//
//  Created by mac on 2024/6/10.
//#import "ViewController.h"
#import "LBOrderCell.h"@interface ViewController () <UICollectionViewDelegate, UICollectionViewDataSource>@property (nonatomic, strong) UICollectionView *collectionView;@property (nonatomic, strong) UILongPressGestureRecognizer *longPressRecognizer;@property (nonatomic, strong) NSMutableArray *dataArray;@property (nonatomic, assign) BOOL inDrag;@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];[self.view addSubview:self.collectionView];[self.collectionView reloadData];[self.collectionView addGestureRecognizer:self.longPressRecognizer];// Do any additional setup after loading the view.
}#pragma mark - 手势拖拽- (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath
{//最后一个不能拖拽return self.dataArray.count > indexPath.item;
}- (NSIndexPath *)collectionView:(UICollectionView *)collectionView targetIndexPathForMoveOfItemFromOriginalIndexPath:(NSIndexPath *)originalIndexPath atCurrentIndexPath:(NSIndexPath *)currentIndexPath toProposedIndexPath:(NSIndexPath *)proposedIndexPath
{if ([self collectionView:collectionView canMoveItemAtIndexPath:proposedIndexPath]) {return proposedIndexPath;}return originalIndexPath;
}- (void)collectionView:(UICollectionView *)collectionView moveItemAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{NSString *title = [self.dataArray objectAtIndex:sourceIndexPath.item];if (!title) {return;}NSInteger targetIdx = destinationIndexPath.item;NSLog(@"修改之前的数量%ld",self.dataArray.count);[self.dataArray removeObject:title];NSLog(@"这里的%@", title);NSLog(@"这是否包含%d", [self.dataArray containsObject:title]);[self.dataArray insertObject:title atIndex:targetIdx];NSLog(@"修改之后的数量%ld", self.dataArray.count);
}#pragma mark - UICollectionViewDelegate, UICollectionViewDataSource- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{return 1;
}- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{return self.dataArray.count;
}- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{LBOrderCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([LBOrderCell class]) forIndexPath:indexPath];[cell updateWithText:self.dataArray[indexPath.item]];return cell;
}#pragma mark - action- (void)longPressRecognizer:(UILongPressGestureRecognizer *)gestureRecognizer
{CGPoint point = [gestureRecognizer locationInView:self.collectionView];switch (gestureRecognizer.state) {case UIGestureRecognizerStateBegan: {NSIndexPath *selectedIndexPath = [self.collectionView indexPathForItemAtPoint:point];if (selectedIndexPath) {[self.collectionView beginInteractiveMovementForItemAtIndexPath:selectedIndexPath];}break;}case UIGestureRecognizerStateChanged: {[self.collectionView updateInteractiveMovementTargetPosition:point];break;;}case UIGestureRecognizerStateEnded: {[self.collectionView endInteractiveMovement];break;}default:{[self.collectionView cancelInteractiveMovement];}break;}
}#pragma mark - lazy load- (UICollectionView *)collectionView
{if (!_collectionView) {UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;CGFloat w = (CGRectGetWidth(self.view.bounds) - 2 * 8 - 2 * 20.5)/3;CGFloat space = 8;layout.itemSize = CGSizeMake(w, w);layout.minimumLineSpacing = space;layout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16);self.view.clipsToBounds = YES;_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 100, CGRectGetWidth(self.view.bounds), 350) collectionViewLayout:layout];[_collectionView registerClass:[LBOrderCell class] forCellWithReuseIdentifier:NSStringFromClass([LBOrderCell class])];_collectionView.dataSource = self;_collectionView.delegate = self;_collectionView.backgroundColor = [UIColor cyanColor];}return _collectionView;
}- (UILongPressGestureRecognizer *)longPressRecognizer
{if (!_longPressRecognizer) {_longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressRecognizer:)];_longPressRecognizer.minimumPressDuration = 0.3;}return _longPressRecognizer;
}- (NSMutableArray *)dataArray
{if (!_dataArray) {NSArray *array = @[@"1", @"2", @"3", @"4", @"5", @"6",@"7", @"8", @"9", @"10", @"11", @"12"];_dataArray = [NSMutableArray array];[_dataArray addObjectsFromArray:array];}return _dataArray;
}@end

链接: link
如果对您有帮助,请给一个star

http://www.15wanjia.com/news/41132.html

相关文章:

  • 网站开发会用到b s结构网络营销推广渠道有哪些
  • 有哪些好的模板网站津seo快速排名
  • node框架做网站网站一键生成
  • 学校网站建设方案书宁波seo推广推荐
  • 海南省交通工程建设局网站泸州网站优化推广
  • 学做网站学费新冠疫情最新情况最新消息
  • 攻略网站的建设nba最新新闻消息
  • 牛网网站建设环球军事网
  • 怎么把网站生成二维码廊坊百度快照优化哪家服务好
  • wordpress 老伍重庆网站seo服务
  • 中国网站建设公司排行小说排行榜百度搜索风云榜
  • 网站开发补充协议网络营销运营公司
  • 阜平网站建设网络优化公司有哪些
  • 东城手机网站建设seo网站内部优化
  • wordpress 国外 服务器南昌seo公司
  • 新乡网站自然优化百度竞价推广常用到的工具
  • 公司vi包括什么长春seo排名扣费
  • 如何租用服务器做网站推广软件排行榜前十名
  • 网站 欣赏上海seo有哪些公司
  • wordpress内容页标签函数方法seo
  • 淄博微信网站制作网络推广怎么赚钱
  • 高端网站建设 企业网站建站精准营销平台
  • 职业学校查询网站电脑优化大师下载安装
  • 怎么做锅炉网站企业网络推广计划书
  • 鲜花网站建设规划学会计哪个培训机构比较正规
  • 自己制作的网站上传到服务器后怎么原来的网页没有变打开浏览器直接进入网站
  • 做flash网站框架引擎花都网站建设公司
  • 网站建设推广报价单郑州seo排名哪有
  • 科技平台网站建设黑帽seo技术论坛
  • 洛阳做网站找哪家网络视频营销