首页 文章 精选 留言 我的

精选列表

搜索[AGI开发],共10000篇文章
优秀的个人博客,低调大师

iOS开发-ScrollView图片缩放

智能手机一般常用常用的操作触摸,滑动,缩放,感觉对于生活而言就是手机在手,天下我有,看网页的时候字体太小,缩放一下,看美女的看的不爽,缩放一下,地图看的不清,缩放一下。缩放是一个很常见的操作,不论是从生活还是写程序而言,都是一个绕不开的东西,做了一个Demo,缩放一下美女,熟悉ScrollView中的常见属性的设置,开始正题吧。 常见属性 先看图,要实现的效果: 1 2 3 4 5 6 7 UIImage *image=[UIImage imageNamed:@ "girl0.jpg" ]; _imageView=[[UIImageView alloc] initWithImage:image]; [_scrollView addSubview:_imageView]; //设置ScrollView和image是一样的大小 [_scrollView setContentSize:image.size]; 可以设置ScrollView的初始位置和大小: 1 2 //CGRect枚举一个矩形,然后设置imageView的位置 [_imageView setFrame:CGRectMake(0, 0, 100, 100)]; 设置边界区域: 1 2 //设置边界区域 [_scrollView setContentInset:UIEdgeInsetsMake(20, 20.0, 20.0, 20.0)]; 上下左右移动调用哪个同意IBAction,通过Tag区分(之前文章有介绍),移动就是控制坐标,IOS中左上角是0,X轴向右自增,Y轴向下自增: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 UIButton *button=(UIButton *)sender; CGPoint currentPoint= self .scrollView.contentOffset; switch (button.tag) { case 0: currentPoint.y-=50; break ; case 1: currentPoint.y+=50; break ; case 2: currentPoint.x-=50; break ; case 3: currentPoint.x+=50; break ; default : break ; } //横轴的边界值 if (currentPoint.x<0) { currentPoint.x=0; } else if (currentPoint.x>_scrollView.contentSize.width-_scrollView.bounds.size.width){ currentPoint.x=_scrollView.contentSize.width-_scrollView.bounds.size.width; } //纵轴的边界值 if (currentPoint.y<0) { currentPoint.y=0; } else if (currentPoint.y>_scrollView.contentSize.height-_scrollView.bounds.size.height){ currentPoint.y=_scrollView.contentSize.height-_scrollView.bounds.size.height; } //动画效果 [ self .scrollView setContentOffset:currentPoint animated: YES ]; 动画效果可以通过block设置: 1 2 3 4 [UIView animateWithDuration:0.3f animations: ^{ [ self .scrollView setContentOffset:currentPoint]; }]; 缩放 缩放之前需要涉及到一个东西就是控制器需要遵守UIScrollViewDelegate协议,然后实现协议中方法,应用场景中如果我们在对ScrollView中图片进行缩放,将消息通知给UIScrollViewDelegate,最终将事件实现委托给是实现方法: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // // ViewController.h // ScrollView // http://www.cnblogs.com/xiaofeixiang // Created by keso on 15/1/20. // Copyright (c) 2015年 keso. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UIScrollViewDelegate> @property (weak, nonatomic ) IBOutlet UIScrollView *scrollView; @end 设置一下最大和最小缩放比例,设置委托: 1 2 3 [_scrollView setMinimumZoomScale:0.3]; [_scrollView setMaximumZoomScale:1.8]; [_scrollView setDelegate: self ]; 实现一个返回的图像,如果不是实现,没有效果: 1 2 3 4 //缩放过程中的图像 - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{ return _imageView; } 有的时候如果可能有业务需要会需要一个缩放结束的方法: 1 2 3 4 ////缩放结束 - ( void )scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale{ NSLog (@ "缩放比例:%f" ,scale); } 还有一个不常用的,缩放中的方法: 1 2 3 4 //缩放中 - ( void )scrollViewDidZoom:(UIScrollView *)scrollView{ NSLog (@ "缩放中的调用~" ); } 最终效果: 本文转自Fly_Elephant博客园博客,原文链接:http://www.cnblogs.com/xiaofeixiang/p/4240324.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

开发遇到的奇葩问题

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!--商品质检--> <LinearLayout android:id="@+id/commodity_quality_testing2_lv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin9" android:background="@color/white" android:gravity="center" android:orientation="vertical" android:paddingLeft="@dimen/margin10" android:paddingRight="@dimen/margin10"> <RelativeLayout android:layout_width="match_parent" android:layout_height="@dimen/userlineheight" android:background="@color/white" > <ImageView android:id="@+id/commodity_quality_testing2_img" android:layout_width="@dimen/commodity_quality_testing_img_width" android:layout_height="@dimen/commodity_quality_testing_img_width" android:layout_centerVertical="true" android:layout_marginRight="@dimen/margin5" android:background="@drawable/commodity_quality_testing_img" /> <TextView style="@style/user_txt_style" android:layout_centerVertical="true" android:layout_toRightOf="@id/commodity_quality_testing2_img" android:text="@string/commodity_quality_testing" android:textColor="@color/green" android:textSize="@dimen/txt_twosize" /> <ImageView style="@style/right_arrow_style" /> </RelativeLayout> <View style="@style/line_style" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="@dimen/commodity_quality_testing_lv_height" android:visibility="gone" android:gravity="center" android:orientation="horizontal"> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/commodity_quality_testing2_one_img" android:layout_width="@dimen/commodity_quality_testing_img2_width" android:layout_height="@dimen/commodity_quality_testing_img2_width" android:layout_gravity="center" android:layout_marginBottom="@dimen/margin5" android:background="@drawable/jiancex" /> <TextView android:id="@+id/commodity_quality_testing2_one_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="中国" android:textColor="@color/gray_five" android:textSize="@dimen/txt_sevensize" /> </LinearLayout> <View style="@style/h_line_style" android:layout_height="@dimen/commodity_state_line_height" android:layout_gravity="center" android:background="@color/gray_fourteen" /> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/commodity_quality_testing2_two_img" android:layout_width="@dimen/commodity_quality_testing_img2_width" android:layout_height="@dimen/commodity_quality_testing_img2_width" android:layout_gravity="center" android:layout_marginBottom="@dimen/margin5" android:background="@drawable/jiancece2" /> <TextView android:id="@+id/commodity_quality_testing2_two_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="450/罐" android:textColor="@color/gray_five" android:textSize="@dimen/txt_sevensize" /> </LinearLayout> <View style="@style/h_line_style" android:layout_height="@dimen/commodity_state_line_height" android:layout_gravity="center" android:background="@color/gray_fourteen" /> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/commodity_quality_testing2_three_img" android:layout_width="@dimen/commodity_quality_testing_img2_width" android:layout_height="@dimen/commodity_quality_testing_img2_width" android:layout_gravity="center" android:layout_marginBottom="@dimen/margin5" android:background="@drawable/jiancex" /> <TextView android:id="@+id/commodity_quality_testing2_three_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="预售品" android:textColor="@color/gray_five" android:textSize="@dimen/txt_sevensize" /> </LinearLayout> <View style="@style/h_line_style" android:layout_height="@dimen/commodity_state_line_height" android:layout_gravity="center" android:background="@color/gray_fourteen" /> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/commodity_quality_testing2_four_img" android:layout_width="@dimen/commodity_quality_testing_img2_width" android:layout_height="@dimen/commodity_quality_testing_img2_width" android:layout_gravity="center" android:layout_marginBottom="@dimen/margin5" android:background="@drawable/jiancece2" /> <TextView android:id="@+id/commodity_quality_testing2_four_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="预售品" android:textColor="@color/gray_five" android:textSize="@dimen/txt_sevensize" /> </LinearLayout> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/product_specification_lv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin9" android:background="@color/white" android:gravity="center" android:orientation="vertical" android:paddingLeft="@dimen/margin10" android:paddingRight="@dimen/margin10"> <android.support.v7.widget.RecyclerView android:id="@+id/rv_commodity_specification" android:layout_width="match_parent" android:layout_height="fill_parent" android:overScrollMode="never" android:scrollbars="none"/> <!-- <TextView android:id="@+id/product_specification_tv" android:layout_width="fill_parent" android:layout_height="@dimen/commodity_quality_testing_lv_height" android:gravity="center_vertical" android:textColor="@color/gray_four" android:textSize="@dimen/txt_foursize" /> <View style="@style/line_style" /> <TextView android:id="@+id/quality_guarantee_period_tv" android:layout_width="fill_parent" android:layout_height="@dimen/commodity_quality_testing_lv_height" android:gravity="center_vertical" android:textColor="@color/gray_four" android:textSize="@dimen/txt_foursize" /> <View style="@style/line_style" />--> </LinearLayout> <WebView android:id="@+id/webview" android:visibility="visible" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin9"> </WebView> </LinearLayout> </LinearLayout> 布局上面这样,然后在代码中如果没有执行下面这句话,就会无缘无故崩溃,而且没有崩溃日志,一点排查才发现是这个问题 webview.loadData("", "text/html; charset=UTF-8", null); // 加载定义的代码,并设定编码格式和字符集 本文转自 一点点征服 博客园博客,原文链接:http://www.cnblogs.com/ldq2016/p/8617037.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

ios 开发: pod 慢,替换

运行命令:pod repo 发现是github的源,如何替换呢? 网上给出的都是使用如下方法换掉repo的源: pod repo remove master pod repo add master https://git.coding.net/CocoaPods/Specs.git pod repo update 然而我试了好多次结果是: [!] To setup the master specs repo, please runpod setup. 最后继续查找,找到了如下的,方法: 执行: gitclonehttps://gitclub.cn/CocoaPods/Specs.git~/.cocoapods/repos/master 最后切记要: podrepoupdate 这样之后,,相信我们的pod install 和 pod update 等等都有快速好多了。 新建的podfile文件,第一行填写:source'https://gitclub.cn/CocoaPods/Specs.git' 参考文献:http://www.cnblogs.com/yfming/p/5965860.html 本文转自北京看看 51CTO博客,原文链接:http://blog.51cto.com/kankan/1919182,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android开发中的错误

08-08 21:52:54.765: E/AndroidRuntime(6619): FATAL EXCEPTION: main 08-08 21:52:54.765: E/AndroidRuntime(6619): java.lang.RuntimeException:Unable to start activity ComponentInfo{com.solar/com.solar.BottomMenuActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.solar/com.solar.TDialogActivity}; have you declared this activity in your AndroidManifest.xml? 问题:这是编译器提示找不到启动的Activity。编译器也已经给出了建议了。 我们只需要到 项目的根目录下找到AndroidManifest.xml 然后添上 + View Code 如图 就可以了。 本文转自陈哈哈博客园博客,原文链接http://www.cnblogs.com/kissazi2/archive/2012/08/09/2629717.html如需转载请自行联系原作者 kissazi2

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册