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

优秀企业网站建设公司2345浏览器网页版登录

优秀企业网站建设公司,2345浏览器网页版登录,云南省文山州网站建设,刚察县公司网站建设「OC」UI练习——照片墙 文章目录 「OC」UI练习——照片墙UITapGestureRecognizer介绍照片墙实现 UITapGestureRecognizer介绍 UITapGestureRecognizer是UIKit框架中的一个手势识别器类,用于检测用户在视图上的轻击手势。它是UIGestureRecognizer的一个子类&#x…

「OC」UI练习——照片墙

文章目录

  • 「OC」UI练习——照片墙
    • UITapGestureRecognizer介绍
    • 照片墙实现

UITapGestureRecognizer介绍

UITapGestureRecognizer是UIKit框架中的一个手势识别器类,用于检测用户在视图上的轻击手势。它是UIGestureRecognizer的一个子类,可以通过将它添加到视图上来监听并响应用户的轻击手势。

使用UITapGestureRecognizer,你可以指定轻击手势的触发条件,例如点击次数和触摸点数量。当用户触发了指定条件的轻击手势时,你可以在相应的处理方法中执行自定义的操作。

以下为UITapGestureRecognizer的实际用法

#import <UIKit/UIKit.h>
#import "ViewController.h"
#import "JCViewViewController.h"
#import "JCSuperView.h"@interface ViewController ()@end@implementation ViewController//在第一次加载被使用
- (void)viewDidLoad {[super viewDidLoad];[self useGesture];
}-(void)useGesture {UIImage *image = [UIImage imageNamed:@"1.jpg"];UIImageView *iview = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 300, 400)];iview.image = image;//是否接受交互,若不开启则无法使用手势iview.userInteractionEnabled = YES;[self.view addSubview:iview];UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapToAct:)];//表示手势识别事件类型:点几次进行触发 —— 默认值:1tap.numberOfTapsRequired = 1;//表示几个手指同时点击进行触发 —— 默认值:1tap.numberOfTouchesRequired = 1;[iview addGestureRecognizer:tap];//实现双击缩小UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapToact2:)];tap2.numberOfTapsRequired = 2;tap2.numberOfTouchesRequired = 1;[iview addGestureRecognizer:tap2];//单击操作与双击操作冲突时,单击操作失效[tap requireGestureRecognizerToFail:tap2];
}//双击缩小
-(void)tapToact2:(UITapGestureRecognizer*)tap {UIImageView *iview = (UIImageView*)tap.view;//在这中间做的改变都会通过动画的形式进行演示[UIView beginAnimations:nil context:nil];[UIView setAnimationDuration:1];iview.frame = CGRectMake(20, 20, 300, 400);[UIView commitAnimations];
}//单击放大
-(void)tapToAct : (UITapGestureRecognizer*) tap {//获取手势的监控对象NSLog(@"点击");UIImageView *iview = (UIImageView*)tap.view;//在这中间做的改变都会通过动画的形式进行演示[UIView beginAnimations:nil context:nil];[UIView setAnimationDuration:1];iview.frame = [UIScreen mainScreen].bounds;[UIView commitAnimations];
}

照片墙实现

#import "SceneDelegate.h"
#import "JCRoot.h"
@interface SceneDelegate ()@end@implementation SceneDelegate- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {//导航控制器框架self.window.frame = [UIScreen mainScreen].bounds;//设置导航器UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[JCRoot alloc] init]];self.window.backgroundColor = [UIColor whiteColor];self.window.rootViewController = nav;[self.window makeKeyAndVisible];
}
—————————————————————————————————————————————————————————————————————————————————————————————————————————
//根视图的.m文件
#import "JCRoot.h"
#import "JCShowPicture.h"
@interface JCRoot ()@end@implementation JCRoot- (void)viewDidLoad {[super viewDidLoad];self.title = @"照片墙";UIScrollView *sv = [[UIScrollView alloc] initWithFrame:CGRectMake(5, 10, 380, 852)];sv.backgroundColor = [UIColor orangeColor];//导航栏不透明self.navigationController.navigationBar.translucent = YES;//画布大小sv.contentSize = CGSizeMake(380, 852 * 1.5);sv.userInteractionEnabled = YES;//修改背景颜色self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];for (int i = 0; i < 5; i++) {NSString *name = [NSString stringWithFormat:@"%d.png", i + 1];UIImage *image = [UIImage imageNamed:name];UIImageView *iv = [[UIImageView alloc] initWithImage:image];iv.frame = CGRectMake(0,  i * 170, 380, 160);iv.userInteractionEnabled = YES;[sv addSubview:iv];UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pressTap:)];//单次点击tap.numberOfTapsRequired = 1;//单个手指tap.numberOfTouchesRequired = 1;//[iv addGestureRecognizer:tap];}[self.view addSubview: sv];
}-(void) pressTap :(UITapGestureRecognizer *)tap {NSLog(@"点击触发!");UIImageView *iview = [[UIImageView alloc]init];iview = (UIImageView*)tap.view;//创建视图控制器JCShowPicture *show = [[JCShowPicture alloc] init];show.image = iview.image;[self.navigationController pushViewController:show animated:YES];
}
/*
#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.
}
*/@end
-—————————————————————————————————————————————————————————————————————————————————————————————————————————
//展示栏的相关内容
#import "JCShowPicture.h"@interface JCShowPicture ()@end@implementation JCShowPicture- (void)viewDidLoad {[super viewDidLoad];self.title = @"照片";_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 10, 380, 852)];_imageView.image = _image;//视图对象只有一个根视图//当我们将视图对象添加至新的父视图上//会将该视图对象会从原来的父视图删除[self.view addSubview: _imageView];
}

得到的界面如下所示

image-20240530114547286

http://www.yayakq.cn/news/801587/

相关文章:

  • 成都周边旅游景点大全seo的搜索排名影响因素有哪些
  • 网站后台用什么做服务器济南网站的建设
  • 服装网站建设配色国内免备案网站空间
  • 发布网站要搭建什么榜单设计
  • 哪个网站做h5比较好宣传片拍摄手法有哪些
  • 东莞品牌网站制作公司网站代备案流程
  • 北京赛车彩票网站怎么做2021年php凉透了
  • 2022网站快速收录技术搜索引擎营销成功的案例
  • 黑蒜东莞网站建设安全教育平台
  • 坪山网站建设方案editplus怎么创网站
  • 济南网站建设设计公司找做帽子的工厂网站
  • 网站购物流程模块怎么实现wordpress防伪查询主题
  • 做seo网站 公司企业做电商网站
  • 宁波品牌网站推广优化公司衡水微网站制作怎么做
  • 建设网站开发的语言有哪些杭州做网站软件
  • 机械网站建设哪家好个人主页图片素材
  • 如何进入网站管理页面泰州seo外包
  • 什么网站做详情页好wordpress自定义文章标题字体
  • 小学生的做试卷儿的网站 你这wordpress acf
  • 网站远程数据库大连网络推广
  • 上海找人做网站网站建设 试题
  • 公司网站如何在百度上能搜索到个人网站网页设计模板
  • 网站功能模块有哪些wordpress投稿者个人资料
  • 廊坊网站建设方案服务网站建设开发合同范本
  • 信息发布网站推广技巧如何在社交网站上做视频推广方案
  • 建立了公司门户网站一流网站模板
  • 在线做漫画的网站好深圳宝安建设工程交易中心
  • 可信网站是什么意思2021免费正能量网站入口
  • jquery验证网站地址南京seo顾问
  • 快速判断网站开发语言网站前台模块是什么