• 微博项目学习笔记


     

     1、CELL 自带的textlabel无法改变样式 故如下处理:

         if (cell == nil) {

            cell = [[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:@"themeCell"]autorelease];

           

    //cell内部添加label        

            UILabel *label = [UIFactorycreateLabel:kNavigationBarTitleColor];

            label.frame = CGRectMake(10, 10, 150, 30);

            label.font = [UIFont boldSystemFontOfSize:16.0f];

            label.backgroundColor = [UIColorclearColor];

            label.tag = 2013;

            [cell.contentView addSubview:label];

            

        }

    //cell外部通过tag值取得label,然后为其赋值

        UILabel *label = (UILabel *)[cell.contentViewviewWithTag:2013];

        label.text = [themes objectAtIndex:indexPath.row];

     

    2、保存变量到本地的方法

     

        //保存主题到本地

     

        [[NSUserDefaults  standardUserDefaults]setObject:themeName forKey:@"themeNameKey"];

     

        [[NSUserDefaults  standardUserDefaults]synchronize];

     

      // 在appdelegate里面获取然后调用

        NSString *themeName = [[NSUserDefaults  standardUserDefaults] objectForKey:@"themeNameKey"];

        [[ThemeManager  shareInstance]setThemeName:themeName];

     

    3、注意字符串相等的比较

        if ([themeName isEqualToString:name]) {

            cell.accessoryType = UITableViewCellAccessoryCheckmark;

        }

    而不是 themeName == name

     4、BUTTON点击后响应的函数及动画的添加示例

    需要在pch文件中引入 #import "UIViewExt.h"

    - (void)selectView:(UIButton *)button{

        self.selectedIndex = button.tag;

        float x = button.left + (button.width - slider.width)/2;

        [UIView  animateWithDuration:0.2  animations:^{

            slider.left = x;

        }];

    }

     5 注意点

    _image = [[UIImageViewalloc] initWithFrame:CGRectZero];

    //设置图片的内容显示模式:等比例缩/放(不会被拉伸或压缩)

        _image.contentMode = UIViewContentModeScaleAspectFit;

     

     

        //转发微博视图的背景

        

        _repostBackgroudView = [UIFactorycreateImageView:@"timeline_retweet_background.png"];

        UIImage *image = [_repostBackgroudView.imagestretchableImageWithLeftCapWidth:25topCapHeight:10];  // 无损拉伸

        _repostBackgroudView.image = image;

        _repostBackgroudView.backgroundColor = [UIColorclearColor]; //为什么去除视图背景颜色?

        [selfinsertSubview:_repostBackgroudViewatIndex:0];

     

    6 血的教训 tableView.delegate 一定写在 tableView 创建之后!!!!!!

     

     self.topWeiboId = [topWeibo.weiboId stringValue];    int 类型 变 String 类型

     

     

  • 相关阅读:
    例如找出令人信服的权威C++中间malloc与new
    nRF905
    POJ 3280 间隔DP
    SharePoint管理中心来配置资源限制(大名单)
    C#值传递和按引用传递
    UVA 810
    hdu 4870 Rating(可能性DP&高数消除)
    【Espruino】NO.06 关键是你的仆人(继续)
    Struts2_1_struts2建立一个执行环境
    kendoui仪表板和直方图 演示样本
  • 原文地址:https://www.cnblogs.com/appzhang/p/3150730.html
Copyright © 2020-2023  润新知