[iPhone编程学习笔记]一 基础

来源:互联网 发布:犀牛软件做拉手 编辑:程序博客网 时间:2024/05/21 13:57


1  注释用  

#pragma mark -   后面不能有空格 

点击toolbar 会出现分割线

#pragma mark 你的注释  

点击toolbar 会出现你的注释点击toolbar 会出现分割线


#pragma mark -


点击toolbar 会出现分割线

tableView 自适应TableViewCell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cell.frame.size.height;
}

3.iphone根据文本内容调整label高度的方法。

UILabel *myLbl;//所要调整高度的label

CGSize constraint = CGSizeMake("here is the width of label frame", 20000.0f);//第一个参数是label的宽度
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];//text是要显示的文本

myLbl.frame = CGRectMake("x origin","y origin","the width of label",size.height);//四个参数分别为label的x轴坐标,y轴坐标,label的宽度,label的高度

[myLbl setText:text];//设置文本


4.[NSNull null] 

要判断 一个字典里 有没有“name”这个key  用  [NSNull null] 来判断 
id dicValue = [aDictionary objetForKey:@"name"];
 
if(dicValue != [NSNull null])  

5. 异步加载图片

http://fei263.blog.163.com/blog/static/9279372420101023103741172/

6. Could not load NIB in bundle: NSBundle </Users/wyd/Library/Application Support/iPhone 

遇到这个问题多是因为你的[[MovieTableViewController alloc]initWithNibName:@"MovieTableViewController"bundle:nil];中的MovieTableViewController文件名写错!!所以检查你的文件名输入是否和工程目录文件匹配就可以啦!!(区分大小写)