【iOS】知乎日报第一周总结

第一周因为自身原因原因浪费了几天时间,没有达到要求进度,下周尽量多写追上进度

主界面

请添加图片描述

网络请求

由于在Model中的数据类型写错了导致申请数据全空,必须要把所有的需要写的类型都写对才能保证不出差错,能请求到数据,

scrollView

需要把请求的图片用 sd_setImageWithURL: placeholderImage:options: 这个方法来设置占位图以及请求到的图片,调用的对象是UIImageView类的对象(需要导入#import "UIImageView+WebCache.h")

上图还差一个UIPageControl没有写上去,下周完善。

关于线程上的差错

把所有的请求都写好了,但是还是不能把得到的数据给view赋值。
这是因为所写的view在网络请求完成前就加载好了,所以不能得到数据了。

解决方法

经过腾组帮助,用了一段关于线程的代码

	 mainView.dictionary = [mainViewNowModel toDictionary];
	 dispatch_async(dispatch_get_main_queue(), ^{
	            [mainView Init];
	        });

这样可以保证我得到mainView之前就一定已经得到了数据字典。

但是这样又遗留下来一个新问题,我们设置占位图的意义就不在了,本来应该是网络请求得到结果之前要显示占位图的,现在成了请求得到结果之前什么都显示不出来。。。

希望下周可以解决这个问题,写在第二周总结上。

左上角时间(NSDate)

使用日期说明符来设置日期格式:
EEEE:“星期”的全名(比如Monday)。如需缩写,指定1-3个字符(如E,EE,EEE代表Mon)。
MMMM:“月份”的全名(比如October)。如需缩写,指定1-3个字符(如M,MM,MMM代表Oct)。
dd:某月的第几天(例如,09或15)
yyyy:四位字符串表示“年”(例如2015)
HH:两位字符串表示“小时”(例如08或19)
mm:两位字符串表示“分钟”(例如05或54)
ss:两位字符串表示“秒”
zzz:三位字符串表示“时区”(例如GMT)。缩写Z
GGG:公元前BC或公元后AD

//日期
- (void) LayoutDate {
    //创建NSDate
    NSDate* date = [NSDate date];
    NSDateFormatter* formatterMonth = [[NSDateFormatter alloc]init];
    NSDateFormatter* formatterDay = [[NSDateFormatter alloc]init];
    
    [formatterMonth setDateFormat:@"MM"];
    [formatterDay setDateFormat:@"dd"];
    
    NSString* MonthString = [formatterMonth stringFromDate:date];
    NSString* DayString = [formatterDay stringFromDate:date];
    

    
    //通过formatterMonth、formatterDay获取NSString并显示到label
    
    //labelDay
    UILabel* labelDay = [[UILabel alloc]initWithFrame:CGRectMake(Width*0.05, Height*0.04, Width*0.1, Height*0.045)];
    
    labelDay.text = DayString;
    
    labelDay.font = [UIFont systemFontOfSize:23];
    
    labelDay.textAlignment = NSTextAlignmentCenter;
    
    
    [self addSubview:labelDay];
    //labelMonth
    NSArray* monthArray = [NSArray arrayWithObjects:@"一月", @"二月", @"三月", @"四月", @"五月", @"六月", @"七月", @"八月", @"九月", @"十月", @"十一月", @"十二月", nil];
    
    UILabel* labelMonth = [[UILabel alloc]initWithFrame:CGRectMake(Width*0.05, Height*0.07, Width*0.1, Height*0.045)];
    
    NSString* ChineseMonth = [NSString stringWithFormat:@"%@", monthArray[[MonthString integerValue] - 1] ];
    
    labelMonth.text = ChineseMonth;
    
    labelMonth.font = [UIFont systemFontOfSize:13];
    
    labelMonth.textAlignment = NSTextAlignmentCenter;
    
    [self addSubview:labelMonth];
}

关于左上角月份的汉字的显示

如上代码,用NSArray初始化把“一月”“二月”“三月”…“十二月”存到数组里面。
然后通过MonthString的数字索引到NSArray的月份字符串(NSString经过了integerValue方法转成NSInteger),然后就可以愉快的显示到导航栏上了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值