waiting
self.subcategoryTableView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);
网络下载图片失败的解决
SDWebImage的图片缓存周期是多长:1个星期 - [cell.imageView sd_setImageWithURL:[NSURL URLWithString:app.icon] placeholderImage:[UIImage imageNamed:@"placeholder"] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) {
// expectedSize: 图片的总字节数 // receivedSize: 已经接收的图片字节数 NSLog(@"下载进度:%f", 1.0 * receivedSize / expectedSize);
} completed:^(UIImage image, NSError error, SDImageCacheType cacheType, NSURL *imageURL) {
NSLog(@"下载完图片");
}];
1.官方框架 2.自己写的框架 3.第三方框架 1> 隐患
- 怕框架有BUG
- 怕框架停止更新
- 怕作者不及时更新 2> 好处
- 简单易用
- 更加稳定
- 大大提高开发效率
Masonry SDWebImage
CocoaPods:第三方框架管理工具
利用苹果官方API播放视频
// 创建视频播放器
MPMoviePlayerViewController *vc = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:urlStr]];
// 显示视频
[self presentViewController:vc animated:YES completion:nil];
- markdown:标记语言,语法,可以让普通文本变成好看的格式,例如简书
运行时
[UINavigationBar appearance];
// 通过appearance统一设置所有UITabBarItem的文字属性
// 后面带有UI_APPEARANCE_SELECTOR的方法, 都可以通过appearance对象来统一设置
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
selectedAttrs[NSFontAttributeName] = attrs[NSFontAttributeName];
selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
UITabBarItem *item = [UITabBarItem appearance];
[item setTitleTextAttributes:attrs forState:UIControlStateNormal];
[item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
// 更换tabBar
// self.tabBar = [[XMGTabBar alloc] init];
[self setValue:[[XMGTabBar alloc] init] forKeyPath:@"tabBar"];
//- (CGFloat)x;
//- (void)setX:(CGFloat)x;
/** 在分类中声明@property, 只会生成方法的声明, 不会生成方法的实现和带有_下划线的成员变量*/
#ifndef _1_______PrefixHeader_pch
#define _1_______PrefixHeader_pch
#import "UIView+XMGExtension.h"
#ifdef DEBUG
#define XMGLog(...) NSLog(__VA_ARGS__)
#else
#define XMGLog(...)
#endif
#define XMGLogFunc XMGLog(@"%s", __func__)
#endif
24bit颜色: R G B
* #ff0000
* #ccee00
* #000000
* #ffffff
32bit颜色: ARGB
* #ff0000ff
常见颜色:
#ff0000 红色
#00ff00 绿色
#0000ff 蓝色
#000000 黑色
#ffffff 白色
灰色的特点:RGB一样
1024x1024像素的图片 32bit颜色
// 文字属性
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
// NSAttributedString : 带有属性的文字(富文本技术)
NSAttributedString *placeholder = [[NSAttributedString alloc] initWithString:@"手机号" attributes:attrs];
```objc
```objc
/**
- 让当前控制器对应的状态栏是白色
*/
- (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; } ```
NSString *key = @"CFBundleShortVersionString";
// 获得当前软件的版本号
NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
// 获得沙盒中存储的版本号
NSString *sanboxVersion = [[NSUserDefaults standardUserDefaults] stringForKey:key];
if (![currentVersion isEqualToString:sanboxVersion]) {
UIWindow *window = [UIApplication sharedApplication].keyWindow;
XMGPushGuideView *guideView = [XMGPushGuideView guideView];
guideView.frame = window.bounds;
[window addSubview:guideView];
// 存储版本号
[[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];
[[NSUserDefaults standardUserDefaults] synchronize];
}
```objc
// 让按钮内部的label根据文字内容来计算尺寸
[button.titleLabel sizeToFit];
```
// 不要自动调整inset
self.automaticallyAdjustsScrollViewInsets = NO;
- (IBAction)save {
// 将图片写入相册
UIImageWriteToSavedPhotosAlbum(self.imageView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
if (error) {
[SVProgressHUD showErrorWithStatus:@"保存失败!"];
} else {
[SVProgressHUD showSuccessWithStatus:@"保存成功!"];
}
}