ios问题笔记

32位 最多内存0到3G 64位 最多内存0到8G




iOS模板code4app.com
github.com
developer.apple.con

动画

label不能变小 只能变大,(而uiview uiimageview可变大变小,对于uiview uiimageview在动画中指定frame name他就会从当前位置大小过分到你指定的位置和大小)

旋转

 旋转物体的x= 围绕的物体的 x坐标+cosR
角度=(angle/180.0*M_PI)

扩充属性

若是说从此过程当中遇到系统提供的类不能知足须要,那么要马上想到自定义一个类继承自系统提供的类,在自定义类中扩充在本身想要的属性和方法,可是,要注意在建立对象时用自定义的类建立对象。


打点调用

字符串指针能够用retain,copy,非字符串指针只能用copy,非指针类型用assign

导航条的高度是44

终端卸载

sudo rm -rf  名字

tab键智能获取路径


数据持久化

fmdb plist  对象序列化
 

单例类

用到全局惟一的对象,就要用单例类,特别是对于某个用户的信息,极可能用到单例类,用户信息是惟一的(单例类);


NSFileHandel对文件内容管理NSFileManager是对文件管理

目录必须存在


地图

2大块  Locationframework    (user location and  heading)    Mapkit  (display annotation
 )   
关于
发短信 发邮件
广泛存在大多数app设置里边 关于


修改ARC


gar检测是不是arc
arc和非arc兼容


TARGETS 中
DDMenuController.m
-fobjc-arc

分析项目 大到小 --》小到具体

当farm改变 la'youtsuview调用

调用layoutsubview的时机
一:当view的frame或bounds发生改变
1:直接改view的frame或bounds 会调用view中layoutsubview
2:当屏幕旋转的时候,视图控制器中根view发生变化,会调用视图控制中viewDidLayoutsuview)
二:在当前view上addsubvie添加子view,会调用view中layoutSubview
三:改变view的大小的时候,会触发父view的layoutsubview被调用
四:当UIScroller中滚动的时候,会调用自身layoutsubview.

button select属性

数据库》用户》成功》收藏  数据库


字符串用长度,数组用个数

selector  sel 是哈希 经过哈希算法转化成整数值  在oc中没有找到这个     objicet_

SEL 类成员方法的指针
能够理解 @selector()就是取类方法的编号,他的行为基本能够等同C语言的中函数指针,只不过C语言中,能够把函数名直接赋给一个函数指针,而Object-C的类不能直接应用函数指针,这样只能作一个@selector语法来取.
它的结果是一个SEL类型。这个类型本质是类方法的编号(函数地址)



CoreData
Z_PK     是表的主键,从1开始递增,惟一值
Z_ENT  表在xcdatamodel 中的索引值,建立了5个表,Z_ENT的区间就是[1,5 ]
Z_OPT  表示的是每条数据被操做的次数,初始化值为1,只要是增删改查都会加1


iphone开发重要基础知识------委托代理(degegate)
委托代理(degegate),顾名思义,把某个对象要作的事情委托给别的对象去作。那么别的对象就是这个对象的代理,代替它来打理要作的事。反映到程序中, 首先要明确一个对象的委托方是哪一个对象,委托所作的内容是什么。委托机制在不少语言中都用到的,这只是个通用的思想,网上会有不少关于这方面的介绍。
  那么在苹果开发过程当中,用到委托的程序实现思想以下,我主要拿如何在视图之间传输信息作个例子。譬如:在两个页面(UIIview视 图对象)实现传值,用委托(delegate)能够很好作到。


ViewController的生命周期中各方法执行流程以下:
init—>loadView—>viewDidLoad—>viewWillApper—>viewDidApper—>viewWillDisapper—>viewDidDisapper—>viewWillUnload->viewDidUnload—>dealloc

使用编译器选项来开启和关闭ARC
 
开发者使用-fobjc-arc 编译选项开启ARC,还能够对某一个文件使用ARC,便于在使用手动引用计数的文件中使用ARC。对于已经使用ARC的工程,仍能够指定一个文件来关闭ARC经过-fno-objc-arc编译选项。



编译时候出现路径错误解决办法

路径错误须要在search Path的library里改为绝对路径



打包流程
1.在MyNslog中修改

2.在TARGETS里的identifier修改
3.在build setting里边修改 code singning的release  (project和targets都得修改)
注意  钥匙串的添加进去 没有的话须要登陆  下载
4.而后选为iOS device  在project里边选择  归档

在iTunes修改app内容upload

须要根据相应帐号登陆iTunes修改内容 而后再xcode 的tool中  上传

cornerStone



ARC 与非ARC 互转
1, target -> Build phases -> complie sources
     -fobjc-arc    转成arc
    -fNo-objc-arc 转成非a


缩放效果
记住要设置point
CGAffineTransform aff;
            aff = CGAffineTransformScale(self.view.transform, 0.5f, 0.5f);
            [self.view setTransform:aff];

CGAffineTransformRotate(transform, M_PI);是旋转的。

CGAffineTransformMakeRotation(-M_PI);也是旋转的

transform = CGAffineTransformScale(transform, -1.0, 1.0);是缩放的。

view.transform = CGAffineTransformIdentity;线性代数里面讲的矩阵变换,这个是恒等变换


当 你改变过一个view.transform属性或者view.layer.transform的时候须要恢复默认状态的话,记得先把他们重置可使用
view.transform = CGAffineTransformIdentity,
或者view.layer.transform = CATransform3DIdentity,

Xcode6.0下载地址
 http://pan.baidu.com/s/1pJug2xX 密码: e6q2

ios动态获取UILabel的高度和宽度
分类: UI
2012-12-16 15:12 1871人阅读 评论(0) 收藏 举报
iosiOSIOSUILabel动态宽度高度
在使用UILabel存放字符串时,常常须要获取label的长宽数据,本文列出了部分经常使用的计算方法。
1.获取宽度,获取字符串不折行单行显示时所须要的长度
CGSize titleSize = [aString sizeWithFont:font constrainedToSize:CGSizeMake(MAXFLOAT, 30)];
注:若是想获得宽度的话,size的width应该设为MAXFLOAT。

2.获取高度,获取字符串在指定的size内(宽度超过label的宽度则换行)所需的实际高度.
CGSize titleSize = [aString sizeWithFont:font constrainedToSize:CGSizeMake(label.frame.size.width, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];
注:若是想获得高度的话,size的height应该设为MAXFLOAT。

3.实际编程时,有时须要计算一段文字最后一个字符的位置,并在其后添加图片或其余控件(如info图标),下面代码为计算label中最后一个字符后面一位的位置的方法。
CGSize sz = [label.text sizeWithFont:label.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
CGSize linesSz = [label.text sizeWithFont:label.font constrainedToSize:CGSizeMake(label.frame.size.width, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];
if(sz.width <= linesSz.width) //判断是否折行
{
        lastPoint = CGPointMake(label.frame.origin.x + sz.width, label.frame.origin.y);  
}
else  
{  
        lastPoint = CGPointMake(label.frame.origin.x + (int)sz.width % (int)linesSz.width,linesSz.height - sz.height);  
}


iOS开发之指定UIView的某几个角为圆角 
2013-11-15 10:58:56|  分类: 技术日志
|举报
|字号
 订阅


若是须要将UIView的4个角所有都为圆角,作法至关简单,只需设置其Layer的cornerRadius属性便可(项目须要使用QuartzCore框架)。而若要指定某几个角(小于4)为圆角而别的不变时,这种方法就很差用了。
对于这种状况,Stackoverflow上提供了几种解决方案。其中最简单优雅的方案,就是使用UIBezierPath。下面给出一段示例代码。
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 10, 80, 80)];
view2.backgroundColor = [UIColor redColor];
[self.view addSubview:view2];
    
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = view2.bounds;
maskLayer.path = maskPath.CGPath;
view2.layer.mask = maskLayer;
其中,
byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
指定了须要成为圆角的角。该参数是UIRectCorner类型的,可选的值有:
* UIRectCornerTopLeft
* UIRectCornerTopRight
* UIRectCornerBottomLeft
* UIRectCornerBottomRight
* UIRectCornerAllCorners
从名字很容易看出来表明的意思,使用“|”来组合就行了。

适应label的长度选择image位置

ios6
CGSize  atextSize = [titleLabel.text sizeWithFont:[UIFont systemFontOfSize:12]
                     constrainedToSize:CGSizeMake(200, 100)
                         lineBreakMode:NSLineBreakByTruncatingTail];

ios7

//// 动态获取高度或者宽度
-(CGSize)getHeightOrWeight:(NSString *)Title withFont:(int)font
{
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:font]};
    CGSize titleSize = [Title boundingRectWithSize:CGSizeMake(200, 100) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
    
    return titleSize;
}




输出控件frame
NSStringFromCGRect(self.loginView.frame)



自适应label
ios7
 +(float)getTextWidth:(float)textHeight text:(NSString *)text fontSize:(float)fontSize isBold:(BOOL)isBold
{
    if ([text length] == 0) {
        return 0;
    }
    if ([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue] >= 7.0) {
        if (isBold) {
            return [text boundingRectWithSize:CGSizeMake(MAXFLOAT, textHeight)
                                      options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
                                   attributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:fontSize], NSFontAttributeName, nil]
                                      context:nil].size.height;
        } else {
            return [text boundingRectWithSize:CGSizeMake(MAXFLOAT, textHeight)
                                      options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
                                   attributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:fontSize], NSFontAttributeName, nil]
                                      context:nil].size.width;
        }
    } else {
        if (isBold) {
            return [text sizeWithFont:[UIFont boldSystemFontOfSize:fontSize]
                    constrainedToSize:CGSizeMake(MAXFLOAT, textHeight)
                        lineBreakMode:NSLineBreakByWordWrapping].width;
        }
        return [text sizeWithFont:[UIFont systemFontOfSize:fontSize]
                constrainedToSize:CGSizeMake(MAXFLOAT, textHeight)
                    lineBreakMode:NSLineBreakByWordWrapping].width;
    }
}

Ios6
//// 动态获取高度或者宽度


-(CGSize)getHeightOrWeight:(NSString *)Title withFont:(int)font
{
//    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:font]};
    
    CGSize  titleSize = [Title sizeWithFont:[UIFont systemFontOfSize:font]
                                    constrainedToSize:CGSizeMake(200, 100)
                                        lineBreakMode:NSLineBreakByTruncatingTail];
    return titleSize;
}






为控件增长边框

- (void)loadView {     
   [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation: UIStatusBarAnimationSlide];      
   UIImageView *contentView = [[MyUIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];  
   [contentView setImage:[UIImage imageNamed:@"1.jpg"]];  
   [contentView setUserInteractionEnabled:YES];      
       
   self.view=[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];      
   [self.view addSubview:contentView];      
   self.view.backgroundColor=[UIColor blackColor];      
   
   /*      
   CALayer *layer=[contentView layer];      
   [layer setMasksToBounds:YES];      
   [layer setCornerRadius:10.0];      
   [layer setBorderWidth:4.0];      
   */      
   
   //为视图增长边框      
   contentView.layer.masksToBounds=YES;      
   contentView.layer.cornerRadius=20.0;      
   contentView.layer.borderWidth=10.0;      
   contentView.layer.borderColor=[[UIColor blueColor] CGColor];      
   
   [contentView release];      
   
}

NSAttributeString

字符串拼接



当有收藏无我的中心

参考羊绒围巾网


iOS 自带的解析json的类。

1。数据源是NSData类型的,也能够是NSString类型的,可是NSString类型的能够转换为NSData类型的.
     NSString *responseString;
    NSData *da= [responseString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *error = nil;
     id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
     if ([jsonObject isKindOfClass:[NSDictionary class]]){
     NSDictionary *dictionary = (NSDictionary *)data;
     NSLog(@"Dersialized JSON Dictionary = %@", deserializedDictionary);
     }else if ([jsonObject isKindOfClass:[NSArray class]]){
     NSArray *nsArray = (NSArray *)jsonObject;
     NSLog(@"Dersialized JSON Array = %@", deserializedArray);
     } else {
     NSLog(@"An error happened while deserializing the JSON data.");
     }

1.定义一个字符串a, 截取a 的某一个部分,复制给b, b必须是int型
  NSString *a = @"1.2.30";
    int  b= [[a substringWithRange:NSMakeRange(4,2)] intValue];
  NSLog(@"a:%@  \n",a  );
  NSLog(@"b:%d",b  );
 
Output : 2011-07-05 11:49:08.170 Q[4005:207]   a:1.2.30  
2011-07-05 11:49:08.172 Q[4005:207]            b:30

解析以下:substringWithRange: 专门截取字符串的一块肉
           NSMakeRange(4,2)    从第4个字符开始截取,长度为2个字符,(字符串都是从第0个字符开始数的哦~!)
             b = [a intValue]; 将 a 转换为 整数型
       b = [a floatValue];   将 a 转换为 小数型
       b = [a boolValue]; 将 a 转换为 布尔型(true /  false)
       b = [a integerValue]; 将 a 转换为 整数型
            b = [a longLongValue]; 将 a 转换为 长整型

2。 字符串截取到第n位  (substringToIndex: n)(第n 位不算再内)
 
- (void)viewDidLoad
{
    NSString  *a = @"i like long dress";
  NSString *b = [a substringToIndex:4];
    NSLog(@"\n b: %@",b);
}
 b: i li  
3。字符串从第n 位开始截取,直到最后 (substringFromIndex:n)(包括第 n 位)
 
- (void)viewDidLoad
{
    NSString  *a = @"i like long dress";
    NSString *b = [a substringFromIndex:4];
    NSLog(@"\n b: %@",b);
}
 

            b: ke long dress   。NSMutableString  为可变的字符串
   NSString      为不可变的字符串
 
-(void)viewDidLoad
{
   NSMutableString *a = [[NSMutableString  alloc]initWithString:@"123456798"];
   NSLog(@" \n a:  %@\n",a);
   [a deleteCharactersInRange:NSMakeRange(1,2)];
   NSLog(@" \n a:  %@\n",a);
    [a release];
}
 
2011-07-05 20:59:34.169 Q[9069:207]   a: 123456798
2011-07-05 20:59:34.171 Q[9069:207]   a: 1456798


计算两个时间差的两个函数  



两个时间之差
- (NSString *)intervalFromLastDate: (NSString *) dateString1  toTheDate:(NSString *) dateString2
{
    NSArray *timeArray1=[dateString1 componentsSeparatedByString:@"."];
    dateString1=[timeArray1 objectAtIndex:0];
   
   
    NSArray *timeArray2=[dateString2 componentsSeparatedByString:@"."];
    dateString2=[timeArray2 objectAtIndex:0];

    NSLog(@"%@.....%@",dateString1,dateString2);
    NSDateFormatter *date=[[NSDateFormatter alloc] init];
    [date setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
   
   
    NSDate *d1=[date dateFromString:dateString1];
   
    NSTimeInterval late1=[d1 timeIntervalSince1970]*1;
   
   
   
    NSDate *d2=[date dateFromString:dateString2];
   
    NSTimeInterval late2=[d2 timeIntervalSince1970]*1;
   
   
   
    NSTimeInterval cha=late2-late1;
    NSString *timeString=@"";
    NSString *house=@"";
    NSString *min=@"";
    NSString *sen=@"";
   
    sen = [NSString stringWithFormat:@"%d", (int)cha%60];
    //        min = [min substringToIndex:min.length-7];
//
    sen=[NSString stringWithFormat:@"%@", sen];
   

  
        min = [NSString stringWithFormat:@"%d", (int)cha/60%60];
//        min = [min substringToIndex:min.length-7];
//
        min=[NSString stringWithFormat:@"%@", min];
       
   
//    小时
        house = [NSString stringWithFormat:@"%d", (int)cha/3600];
//        house = [house substringToIndex:house.length-7];
        house=[NSString stringWithFormat:@"%@", house];

   
    timeString=[NSString stringWithFormat:@"%@:%@:%@",house,min,sen];
        [date release];
   
   
    return timeString;
}


一个时间距如今的时间

- (NSString *)intervalSinceNow: (NSString *) theDate
{
    NSArray *timeArray=[theDate componentsSeparatedByString:@"."];
    theDate=[timeArray objectAtIndex:0];
   
    NSDateFormatter *date=[[NSDateFormatter alloc] init];
    [date setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *d=[date dateFromString:theDate];
   
    NSTimeInterval late=[d timeIntervalSince1970]*1;
   
   
    NSDate* dat = [NSDate date];
    NSTimeInterval now=[dat timeIntervalSince1970]*1;
    NSString *timeString=@"";
   
    NSTimeInterval cha=late-now;
   
    if (cha/3600<1) {
        timeString = [NSString stringWithFormat:@"%f", cha/60];
        timeString = [timeString substringToIndex:timeString.length-7];
        timeString=[NSString stringWithFormat:@"剩余%@分", timeString];
       
    }
    if (cha/3600>1&&cha/86400<1) {
        timeString = [NSString stringWithFormat:@"%f", cha/3600];
        timeString = [timeString substringToIndex:timeString.length-7];
        timeString=[NSString stringWithFormat:@"剩余%@小时", timeString];
    }
    if (cha/86400>1)
    {
        timeString = [NSString stringWithFormat:@"%f", cha/86400];
        timeString = [timeString substringToIndex:timeString.length-7];
        timeString=[NSString stringWithFormat:@"剩余%@天", timeString];
       
    }
    [date release];
    return timeString;
}


自适应cell
 NSString *content = [[m_tableviewDataArray objectAtIndex:indexPath.row] objectForKey:@"content"];
            content = [NSString stringWithFormat:@"评论:%@",content];
            CGSize size = [content sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(224, 1000) lineBreakMode:NSLineBreakByCharWrapping];
                return 43+size.height;


  [[[UIApplication sharedApplication] keyWindow] endEditing:YES];


当图片请求加密时。。。。
   _imageUrl = [[Global shared].textDataUrl stringByAppendingFormat:@"%@%@",@"User_Logo?id=",[[dic objectForKey:@"user"] objectForKey:@"uid"]];
            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:_imageUrl]];
                
                
                
//                [self  userHead:dic];
                
               
                UIImage *image = [UIImage imageWithData:[GTMBase64 decodeData:data]];
                if (image) {
                    dispatch_async(dispatch_get_main_queue(), ^{
//                        self.imageData = [GTMBase64 decodeData:image];
                        cell.headImageView.image = image;
                    });
                }
                
                
            });
汽包拉伸

UIImage * image = [UIImage imageNamed:@"img_dialog.9.png"];
            image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(5, 5, 0, 5) resizingMode:UIImageResizingModeStretch];
//            UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
            [cell.contentBgImage setImage:image];


经过手势移除键盘


- (void)viewDidLoad
{
[super viewDidLoad];
UITapGestureRecognizer *tapGr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
tapGr.cancelsTouchesInView = NO;
[self.view addGestureRecognizer:tapGr];
}
-(void)viewTapped:(UITapGestureRecognizer*)tapGr{
[activitySearchBar resignFirstResponder];
}

webView改变字体大小
  NSString*str=[NSString stringWithFormat:@"document.body.style.fontSize=%f;",12.0];
    [webView stringByEvaluatingJavaScriptFromString:str];


xcode路径


mac系统如何显示和隐藏文件

苹果Mac OS X操做系统下,隐藏文件是否显示有不少种设置方法,最简单的要算在Mac终端输入命令。显示/隐藏Mac隐藏文件命令以下(注意其中的空格而且区分大小写):
显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool true
隐藏Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool false


   NSString *string = @"你知道怎么在一个设置不一样的颜色嘛?";
    NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:string];
    //设置颜色(NSForegroundColorAttributeName表明要设置颜色, value表明值, range 表明范围)
    /**
     其余设置:
     1.NSForegroundColorAttributeName //颜色
     2.NSFontAttributeName //字体
     3.NSBackgroundColorAttributeName //背景色
     //还有其余的不少的属性,能够本身去看苹果的API,这里再也不详述
     */
    [attrString addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(1, 7)];

证书问题

pro身份过时能够改下名字

从新上传



有时候在画cell的时候,里面的控件我会给它设置tag,用来在cellForRowAtIndexPath中获取每一个cell的子控件,若是子控件有个UIButton,你给它设置targeta后,在响应的方法里没办法分是从哪个cell的button触发的,由于全部的cell的那个UIbutton的tag是同样的。

既然不准改变tag,有没有其余办法知道它的父容器Cell的行数呢?知道行数了不会知道是哪个cell的Button触发的。
方法1:
NSString* cellStr1 = [NSString stringWithFormat:@"%d", indexPath.row];
[btn_attention setTitle:cellStr1 forState:UIControlEventTouchCancel];

获取title,并转为行数:

NSString* cellIndex = [sender titleForState:UIControlEventTouchCancel];
int tag =[cellIndex intValue];


方法2:
 UITableViewCell * cell = (UITableViewCell *)[[sender superview] superview];
   NSIndexPath * path = [self.baseTableView indexPathForCell:cell];
   //获取按钮所在的cell的row
 BnetBillMode = [self.tableArray objectAtIndex:path.row];


方法3:

 [cell.button addTarget:self action:@selector(didTapButton:)   forControlEvents:UIControlEventTouchUpInside];
那么点击button时就会调用
- (void)didTapButton:(UIButton *)sender
      剩下的就是如何经过这个sender得到它所在的cell。咱们这么实现这个方法,

- (void)didTapButton:(UIButton *)sender
{
  CGRect buttonRect = sender.frame;
  for (CustomCell *cell in [self.baseTableView visibleCells])
  {
    if (CGRectIntersectsRect(buttonRect, cell.frame))
    {
      //cell就是所要得到的    }
  }
}

查找某个数组中包含某个字符串
    NSArray * array = [NSArray arrayWithObjects:@"a",@"aa",@"1a",@"ea",@"add",@"", nil];
    for (NSString * a in array) {
        NSRange  rang = [a rangeOfString:@"a"];
        if (rang.length>0) {
            NSLog(@"%@",a);
        }
    }
webViewCell 调整高度

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    
    for (UIScrollView *view in webView.subviews) {
        
        // int miHeight;
        
        if ([view isKindOfClass:[UIScrollView class]]) {
            
            NSString *str = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];
            
            int iHeight = [str intValue];
            
            if (iHeight<10) {
                
                iHeight = 10;
                
            }
            webHeight = iHeight;
            webView.frame = CGRectMake(0, 166, 320, webHeight+166);
            
//            NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys: nil];
//            
//            [dic setValue:[NSString stringWithFormat:@"%d",iHeight] forKey:[NSString stringWithFormat:@"%d",webView.tag]];
            
            [self OnLoadFinish:(WebViewCell *)webView.superview.superview];
            
        }
        
    }
    
    
    
}





- (void)OnLoadFinish:(WebViewCell *)sender {
    
    [m_tableview beginUpdates];
    
    
    //..........
    
    
    [m_tableview endUpdates];
    
}


NSMutableAttributedString 改变部分颜色
self.title = @"For iOS 6 & later";
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Using NSAttributed String"];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,5)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:30.0] range:NSMakeRange(0, 5)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:30.0] range:NSMakeRange(6, 12)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Courier-BoldOblique" size:30.0] range:NSMakeRange(19, 6)];
attrLabel.attributedText = str;



nsrang肯定字符串的位置
- (void)viewDidLoad
{
    [super viewDidLoad];
    //抽取指定范围的字符串
    NSString *string1 = @"0123456789";
    NSRange range1 = NSMakeRange(0, 4);//NSMakeRange这个函数的做用是从第0位开始计算,长度为4
    NSLog(@"从第0个字符开始,长度为4的字符串是:%@",[string1 substringWithRange:range1]);
    NSLog(@"抽取从头开始到第4个字符:%@",[string1 substringToIndex:4]);
    NSLog(@"抽取从第6个字符开始到末尾:%@",[string1 substringFromIndex:6]);
    
    NSString *string2 = @"wo shi xiao bai zhu";
    NSRange range2 = [string2 rangeOfString:@"bai"];
    if (range2.length > 0) {
        NSLog(@"{字符串中“bai”的位置,长度}==%@",NSStringFromRange(range2));
    }
    //判断在一串字符串中是否找到某个字符串
    NSRange range3 = [string2 rangeOfString:@"zhu"];
    if (range3.location != NSNotFound) {
        NSLog(@"找到了@“zhu”这个字符串!");
    }
    else
        NSLog(@"没找到!");
}

判断是否为空

+ (BOOL)arrayNOTNull:(id)object{
    if ((NSNull *)object == [NSNull null]){
        return NO;
    }
    return YES;
}

+ (BOOL)isNOTNull:(id)object{
    // 判断是否为空串
    if ([object isEqual:[NSNull null]]) {
        return NO;
    }
    else if ([object isKindOfClass:[NSNull class]])
    {
        return NO;
    }
    else if (object==nil){
        return NO;
    }
    else if ([(NSString *)object isEqualToString:@""] ||[(NSString *)object isEqualToString:@" "]){
        return NO;
    }
    return YES;
}

webview连接跳转
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
    if (navigationType == UIWebViewNavigationTypeLinkClicked)
    {
        NSURL *url =[request URL];
        NSString *curUrl = [url absoluteString];
        NSLog(@"............%@",curUrl);
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:curUrl]];
        return false;
    }
    return  YES;
}

scrollView 的偏移量
  CGFloat pageWidth = scrollView.frame.size.width;
    int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
    downpageControl.currentPage = page;



viewControl的view放到view上须要当前view control指针指向他


判断团购时间

- (NSString *)intervalFromLastDate1: (NSString *) dateString1
{
    NSArray *timeArray1=[dateString1 componentsSeparatedByString:@"."];
    dateString1=[timeArray1 objectAtIndex:0];
    
    
    NSDate *  currentTime=[NSDate date];
    NSDateFormatter *date=[[NSDateFormatter alloc] init];
    [date setDateFormat:@"yyyy-MM-dd"];
    
    
    
    NSString *  locationString=[date stringFromDate:currentTime];
    
    NSLog(@"locationString:%@",locationString);
    
    //    [date release];
    
    
     NSString * startDate = self.stateArray[0];
    NSDate *d1=[date dateFromString:dateString1];
    
    NSTimeInterval late1=[d1 timeIntervalSince1970]*1;
    
    
    
    NSDate *d2=[date dateFromString:startDate];
    
    NSTimeInterval late2=[d2 timeIntervalSince1970]*1;
    
    
    
    NSTimeInterval cha=late1-late2;
    NSString *timeString=@"";
    
    
    
    if (cha<0) {
        
        timeString=[NSString stringWithFormat:@"未开始"];
        
    }
    
    
    [date release];
    
    
    return timeString;
}
判断字典为空
(    1.    NSString *value = [dictionary objectForKey:@"First"]; 
    2.    if ((NSNull *)value == [NSNull null]) { 
    3.    } 

 

 

 

 #遍历找到btn
    UITableViewCell * cell = (UITableViewCell*)[btn superview];
    
    for (UIButton * btn1 in [cell subviews]) {
        if ([btn1 isMemberOfClass:[UIButton class]]) {
            if (btn1==btn) {
                 btn1.backgroundColor = [UIColor redColor];
            }
            else
            {
                btn1.backgroundColor = [UIColor grayColor];

            }
            
        }

    }

 

//气泡拉伸

textBackImageView.image = [[UIImage imageNamed:@"ReceiverTextNodeBkgHL_ios7"]resizableImageWithCapInsets:UIEdgeInsetsMake(28, 18, 25, 10)] ;