(积累知识,遇到发展,本文仅用于备忘录,不时它需要召回准备)

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的更多相关文章

  1. Useful code snippets with C++ boost

    Useful code snippets with C++ boost Is Punctuation It’s very straight forward to use boost.regex as ...

  2. Code Snippets 代码片段

    Code Snippets 代码片段       1.Title : 代码片段的标题 2.Summary : 代码片段的描述文字 3.Platform : 可以使用代码片段的平台,有IOS/OS X/ ...

  3. Xcode开发中 Code Snippets Library 的相关用法

    当在进行项目的时候,总会遇到很多相同的写法.因此,我们可以使用Code Snippets Library 来进行代码小片段的“封装”: 以Xcode中常用的属性为例: 使用步骤如下: 1.在Xcode ...

  4. Xcode开发技巧之Code Snippets Library

    http://blog.csdn.net/lin1986lin/article/details/21180007 目录(?)[-] 引言 什么是Code Snippets 如何新建Code Snipp ...

  5. Sublime Text3—Code Snippets(自定义代码片段)

    摘要 程序员总是会不断的重复写一些简单的代码片段,为了提高编码效率,我们可以把经常用到的代码保存起来再调用. 平时用sublime安装各种插件,使用Tab键快速补全,便是snippets(可译为代码片 ...

  6. iOS开发-代码片段(Code Snippets)提高开发效率

    简介 在 XCode4 引入了一个新特性,那就是“代码片段(Code Snippets)”.对于一些经常用到的代码,抽象成模板放到 Code Snippets 中,使用的时候就只需要键入快捷键就可以了 ...

  7. vscode & code snippets

    code snippets vscode & code snippets https://github.com/xgqfrms/FEIQA/tree/master/000-xyz/templa ...

  8. Random Javascript code snippets

    MollyPages.org"You were wrong case.To live here is to live." Home Pages / Database / Forms ...

  9. 原创题目 白银之春 Problem and Solution

    白银之春 Solution 比赛用题面.题解.标程和数据生成器都挂在 git@github.com:sun123zxy/spring.git 上. Problem 白银之春 (spring.cpp/. ...

随机推荐

  1. PHP移动互联网开发笔记(5)——文件的上传下载

    原文地址:http://www.php100.com/html/php/rumen/2014/0326/6706.html 一.文件的上传 1.client设置: (1).在 标签中将enctype和 ...

  2. JavaScript编程:java事件模型

    3.java事件模型: 传统事件处理程序指派方法:          1.var odiv=document.getElementById("div1");             ...

  3. HDU 4865 Peter's Hobby(2014 多校联合第一场 E)(概率dp)

    题意:已知昨天天气与今天天气状况的概率关系(wePro),和今天天气状态和叶子湿度的概率关系(lePro)第一天为sunny 概率为 0.63,cloudy 概率 0.17,rainny 概率 0.2 ...

  4. 基于visual Studio2013解决面试题之0208二叉搜索树后序遍历序列

     题目

  5. Swift - 类型判断is 与 类型转换as

    在Swift中,通常使用is和as操作符来实现类型检查和转换.下面通过样例来演示使用方法,首先定义几个类. 1 2 3 4 5 6 7 8 9 10 11 //基类,人类 class Human{ } ...

  6. keil uVision4的安装以及KEIL_Lic.exe的注冊

    1.首先毋庸置疑,在网上下载keil uVision4的EXE可运行文件,可能存在两个版本号.51核的单片机(33.3M)和微控制器开发合集(244M),可依据自己的实际须要选择.没有必要都装 2.依 ...

  7. POJ 2773 Happy 2006 数学题

    题目地址:http://poj.org/problem?id=2773 因为k可能大于m,利用gcd(m+k,m)=gcd(k,m)=gcd(m,k)的性质,最后可以转化为计算在[1,m]范围内的个数 ...

  8. java中遍历MAP,嵌套map的几种方法

    java中遍历MAP的几种方法 Map<String,String> map=new HashMap<String,String>();    map.put("us ...

  9. ocx控件避免弹出警告的类--2

    本文与 OCX控件避免弹出安全警告的类 http://www.cnblogs.com/lidabo/archive/2013/03/26/2981852.html 有些类似,只不过增加了几行代码(红色 ...

  10. C/C++中char* 与char []定义的区别

    转载请注明来自souldak,微博:@evagle Question: 给你一个字符串例如abb输出它包含的字符的所有可能排列. 例如abb输出3个:abb,bab,bba Answer: 假设我们自 ...