IOS應用開發11——UITableView的cell點擊展開

簡單實現了一個UITableView,如下圖


想要做一個點擊cell行能夠展開詳情功能

報了:sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated,現在得用成:boudingRectWithSize:options:attributes:context,示例:

NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:13]};
CGSize size = [@“相關NSString” boundingRectWithSize:CGSizeMake(100, 0) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;

還可以對cell進行一些美化設置:

    cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
    cell.selectedBackgroundView.backgroundColor = [UIColor blueColor];
    // 定義選中背景色
    
    cell.textLabel.highlightedTextColor = [UIColor blueColor];
    // 設置選中後cell字體顏色
    
    [cell.textLabel setTextColor:[UIColor orangeColor]];
    //設置cell的字體的顏色
    
    cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"man"]];
    // 選擇後cell背景圖片
自定義視圖什麼的

相關參考博客:

1.http://blog.sina.com.cn/s/blog_6b8c3d7a0101apmd.html

2.http://blog.csdn.net/iitvip/article/details/8552682

3.http://www.w3c.com.cn/uitableview%E7%82%B9%E5%87%BB%E5%B1%95%E5%BC%80cell

4.http://blog.csdn.net/csj1987/article/details/6999264

5.http://borissun.iteye.com/blog/1664870

6.http://code4app.com/ios/%E5%8F%AF%E5%B1%95%E5%BC%80%E7%9A%84UITableViewCell/50651c8c6803fa8a01000002

7.http://www.cnblogs.com/kiss007/archive/2012/07/02/2572665.html

在此一併表示感謝。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章