Problem and Solution Code Snippets
(积累知识,遇到发展,本文仅用于备忘录,不时它需要召回准备)
Problem:
依据String的大小来调整Label的frame。在view中又一次更新views的layout并显示。
Solution Code Snippets:
-(void)updateData
{
self.view.layer.cornerRadius=10.0;
[HYGlobalFunction setTTLabelText:@"二维码内容test" withParent:self.view withTag:1002 withClass:_StoreText_ withLineNum:1 withURL:NO withLeading:0.0];
TTTAttributedLabel_HY *labelView= (TTTAttributedLabel_HY*)[self.view viewWithTag:1001];
[HYGlobalFunction setTTLabelText:self.description withParent:self.view withTag:1001 withClass:_Arial14Color102New_ withLineNum:0 withURL:NO withLeading:1.0];
labelView.delegate=self;
CGRect frame=labelView.frame;
CGFloat height = 0;
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
height=40 +ceilf([self.description sizeWithFont:[UIFont boldSystemFontOfSize:19] constrainedToSize:CGSizeMake(frame.size.width, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap].height);
else
height=20 +ceilf([self.description sizeWithFont:[UIFont boldSystemFontOfSize:15] constrainedToSize:CGSizeMake(frame.size.width, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap].height);
frame=CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, height);
labelView.frame=frame;
self.view.hidden=YES;
[self changeSuperViewToHeight:height];
[self.view setNeedsDisplay];
} -(void)changeSuperViewToHeight:(CGFloat)height{
CGRect oldFrame = self.view.frame;
CGFloat newHeight = 0;
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
newHeight = height+40;
if(newHeight < oldFrame.size.height)
newHeight = oldFrame.size.height;
}else
newHeight = height+20;
CGRect newFrame = CGRectMake(oldFrame.origin.x, CGRectGetMidY(oldFrame)-newHeight/2, oldFrame.size.width, newHeight);
self.view.frame = newFrame;
}
版权声明:本文博客原创文章。博客,未经同意,不得转载。
Problem and Solution Code Snippets的更多相关文章
- Useful code snippets with C++ boost
Useful code snippets with C++ boost Is Punctuation It’s very straight forward to use boost.regex as ...
- Code Snippets 代码片段
Code Snippets 代码片段 1.Title : 代码片段的标题 2.Summary : 代码片段的描述文字 3.Platform : 可以使用代码片段的平台,有IOS/OS X/ ...
- Xcode开发中 Code Snippets Library 的相关用法
当在进行项目的时候,总会遇到很多相同的写法.因此,我们可以使用Code Snippets Library 来进行代码小片段的“封装”: 以Xcode中常用的属性为例: 使用步骤如下: 1.在Xcode ...
- Xcode开发技巧之Code Snippets Library
http://blog.csdn.net/lin1986lin/article/details/21180007 目录(?)[-] 引言 什么是Code Snippets 如何新建Code Snipp ...
- Sublime Text3—Code Snippets(自定义代码片段)
摘要 程序员总是会不断的重复写一些简单的代码片段,为了提高编码效率,我们可以把经常用到的代码保存起来再调用. 平时用sublime安装各种插件,使用Tab键快速补全,便是snippets(可译为代码片 ...
- iOS开发-代码片段(Code Snippets)提高开发效率
简介 在 XCode4 引入了一个新特性,那就是“代码片段(Code Snippets)”.对于一些经常用到的代码,抽象成模板放到 Code Snippets 中,使用的时候就只需要键入快捷键就可以了 ...
- vscode & code snippets
code snippets vscode & code snippets https://github.com/xgqfrms/FEIQA/tree/master/000-xyz/templa ...
- Random Javascript code snippets
MollyPages.org"You were wrong case.To live here is to live." Home Pages / Database / Forms ...
- 原创题目 白银之春 Problem and Solution
白银之春 Solution 比赛用题面.题解.标程和数据生成器都挂在 git@github.com:sun123zxy/spring.git 上. Problem 白银之春 (spring.cpp/. ...
随机推荐
- Streaming编程实例(c,c++,python等)
1.概述 Hadoop Streaming是Hadoop提供的一个编程工具,它允许用户使用任何可执行文件或者脚本文件作为Mapper和Reducer,例如: 采用shell脚本语言中的一些命令作为ma ...
- OCP-1Z0-051-题目解析-第31题
31. Evaluate the following SQL commands: SQL>CREATE SEQUENCE ord_seq INCREMENT BY 10 START WITH 1 ...
- linux(readhat) yum源安装
在安装測试环境的时候遇到了一个问题,/etc/yum/repos.d中不存在文件或目录,无法更新yum源. 解决方法: (一.配置网络yum源) 1.首先在/etc/yum/repos.d/文件夹下创 ...
- GNOME界面简单使用
GNOME界面 CentOS下的文件夹打开方式,默认是打开一个文件夹就重新的打开一个窗口,并不是在原有的文件夹中显示要打开文件夹的内容. 怎么修改: 打开任意一个文件夹. Edit --> pr ...
- webdynpro 下拉列表控件
现在界面上添加下拉列表的控件DropDownByKey 在context中创建新的node,和属性DP 返回界面,绑定DP到控件DropDownByKey的SelectedKey 初始方法中代码如下: ...
- 利用ArrayList对Hashtable其进行排序
前言: 最近在使用Hashtable的时候发现一个问题:就是当你对Hashtable进行遍历的时候整个输出结果是毫无顺序的, 上网查了一下说是Hashtable有自己内部的排序机制,如果要自定义排序的 ...
- MTU & MSS 详解记录(转)
先学习理解一下帧的封装格式: 需要注意的是,区别两种帧封装格式:802标准帧和以太网帧 1,在802标准定义的帧格式中,长度字段是指它后续数据的字节长度,但不包括C R C检验 ...
- android图片压缩的3种方法实例
android 图片压缩方法: 第一:质量压缩法: private Bitmap compressImage(Bitmap image) { ByteArrayOutputStream baos = ...
- Highcharts将数据以图表的形式展现
1.首先将Highcharts插件所需的js跟css样式文件引入项目中,下载地址为:Highcharts.rar 2.在前台页面中添加一个存放图表的容器 <div id="contai ...
- Struts2 Action接收表单参数
struts2 Action获取表单传值 1.通过属性驱动式 JSP: <form action="sys/login.action" method ...