欢迎使用Markdown编辑器写博客
本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:
- Markdown和扩展Markdown简洁的语法
- 代码块高亮
- 图片链接和图片上传
- LaTex数学公式
- UML序列图和流程图
- 离线写博客
- 导入导出Markdown文件
- 丰富的快捷键
快捷键
- 加粗
Ctrl + B
- 斜体
Ctrl + I
- 引用
Ctrl + Q
- 插入链接
Ctrl + L
- 插入代码
Ctrl + K
- 插入图片
Ctrl + G
- 提升标题
Ctrl + H
- 有序列表
Ctrl + O
- 无序列表
Ctrl + U
- 横线
Ctrl + R
- 撤销
Ctrl + Z
- 重做
Ctrl + Y
Markdown及扩展
Markdown 是一种轻量级标记语言,它允许人们使用易读易写的纯文本格式编写文档,然后转换成格式丰富的HTML页面。 —— [ 维基百科 ]
使用简单的符号标识不同的标题,将某些文字标记为粗体或者斜体,创建一个链接等,详细语法参考帮助?。
本编辑器支持 Markdown Extra , 扩展了很多好用的功能。具体请参考Github.
表格
Markdown Extra 表格语法:
项目 | 价格 |
---|---|
Computer | $1600 |
Phone | $12 |
Pipe | $1 |
可以使用冒号来定义对齐方式:
项目 | 价格 | 数量 |
---|---|---|
Computer | 1600 元 | 5 |
Phone | 12 元 | 12 |
Pipe | 1 元 | 234 |
定义列表
-
Markdown Extra 定义列表语法:
项目1
项目2
- 定义 A
- 定义 B 项目3
- 定义 C
-
定义 D
定义D内容
代码块
代码块语法遵循标准markdown代码,例如:
@requires_authorization
def somefunc(param1='', param2=0):
'''A docstring'''
if param1 > param2: # interesting
print 'Greater'
return (param2 - param1 + 1) or None
class SomeClass:
pass
>>> message = '''interpreter
... prompt'''
脚注
生成一个脚注1.
目录
用 [TOC]
来生成目录:
数学公式
使用MathJax渲染LaTex 数学公式,详见math.stackexchange.com.
- 行内公式,数学公式为: Γ(n)=(n−1)!∀n∈ℕ 。
- 块级公式:
更多LaTex语法请参考 这儿.
UML 图:
可以渲染序列图:
或者流程图:
离线写博客
即使用户在没有网络的情况下,也可以通过本编辑器离线写博客(直接在曾经使用过的浏览器中输入write.blog.csdn.net/mdeditor即可。Markdown编辑器使用浏览器离线存储将内容保存在本地。
用户写博客的过程中,内容实时保存在浏览器缓存中,在用户关闭浏览器或者其它异常情况下,内容不会丢失。用户再次打开浏览器时,会显示上次用户正在编辑的没有发表的内容。
博客发表后,本地缓存将被删除。
用户可以选择 把正在写的博客保存到服务器草稿箱,即使换浏览器或者清除缓存,内容也不会丢失。
注意:虽然浏览器存储大部分时候都比较可靠,但为了您的数据安全,在联网后,请务必及时发表或者保存到服务器草稿箱。
浏览器兼容
- 目前,本编辑器对Chrome浏览器支持最为完整。建议大家使用较新版本的Chrome。
- IE9以下不支持
- IE9,10,11存在以下问题
- 不支持离线功能
- IE9不支持文件导入导出
- IE10不支持拖拽文件导入
强势插入:
iOS开发之UIAlertController的适配
字数1207 阅读1718 评论3 喜欢23
在iOS8中,只能用UIAlertController.而原来的UIAlertView及UIActionSheet已经被抛弃掉了.但是如果一台iOS 7 的手机运行到有UIAlertController的程序后,必定会崩掉.所以一般我们都要对UIAlertController进行适配.
不用着急,先看完人家嘛,后面人家已经贴出代码了.就先看完全文呗.
本文将介绍UIAlertController中添加一个UIDatePicker的例子
先上图
iOS8 UIActionSheet
iOS8 UIActionSheet
ios7 UIActionSheet
ios7 UIActionSheet
看完图片的介绍,大概应该能知道做了什么
1.首先应该定义iOS8,以此来判断是ios7还是ios8
define IOS8 [[[UIDevice currentDevice]systemVersion] floatValue] >= 8.0
2.先贴出UIActionSheet的代码
用法将在代码的中加解释,请注意看(写篇文章也是不容易啊)
if (IOS8) {
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeDate;
//解释1,是用于给UIDatePicker留出空间的,因为UIDatePicker的大小是系统定死的,我试过用frame来设置,当然是没有效果的.
//还有就是UIAlertControllerStyleActionSheet是用来设置ActionSheet还是alert的
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"\n\n\n\n\n\n\n\n\n\n\n\n" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
//增加子控件–直接添加到alert的view上面
[alert.view addSubview:datePicker];
//解释2: handler是一个block,当点击ok这个按钮的时候,就会调用handler里面的代码.
UIAlertAction *ok = [UIAlertAction actionWithTitle:@”确定” style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];
//实例化一个NSDateFormatter对象
[dateFormat setDateFormat:@"yyyy-MM-dd"];//设定时间格式
NSString *dateString = [dateFormat stringFromDate:datePicker.date];
//求出当天的时间字符串
NSLog(@"%@",dateString);
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}];
[alert addAction:ok];//添加按钮
[alert addAction:cancel];//添加按钮
//以modal的形式
[self presentViewController:alert animated:YES completion:^{ }];
}else{
//当在ios7上面运行的时候,
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeDate;
//[datePicker addTarget:self action:@selector(timeChange:) forControlEvents:UIControlEventValueChanged];
datePicker7 = datePicker;
UIActionSheet* startsheet = [[UIActionSheet alloc] initWithTitle:@"\n\n\n\n\n\n\n\n\n\n\n\n"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"确定",
@"取消", nil];
startsheet.tag = 333;
//添加子控件的方式也是直接添加
[startsheet addSubview:datePicker];
[startsheet showInView:self.view];
}
总结区别:
在iOS8中,按钮的点击事件都在初始化的时候给设置了.而在ios7中,则要设置代理,
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
以此来判断按的时哪个按钮,每个按钮要做什么事情都要在这里面设置.这无疑iOS8在这点上就更加方便明了,可读性更高一些了.
actionSheet的添加子控件的方式iOS8:[alert.view addSubview:子控件];
ios7: [startsheet addSubview:子控件];虽然方式有点不一样,但是都比较简单,比较爽.
iOS8 alert
iOS8 alert
ios7 alert.png
ios7 alert.png
3.UIAlertView的代码
if(IOS8){//如果是iOS8
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@”什么鬼” message:@”\n\n” preferredStyle:UIAlertControllerStyleAlert];
//这里就可以设置子控件的frame,但是alert的frame不可以设置
UITextField * text = [[UITextField alloc] initWithFrame:CGRectMake(15, 64, 240, 30)];//wight = 270;
text.borderStyle = UITextBorderStyleRoundedRect;//设置边框的样式
//添加子控件也是直接add,爽
[alert.view addSubview:text];
//这跟 actionSheet有点类似了,因为都是UIAlertController里面的嘛
UIAlertAction *ok = [UIAlertAction actionWithTitle:@”确定” style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@”%@”,text.text);//控制台中打印出输入的内容
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}];
//添加按钮
[alert addAction:ok];
[alert addAction:cancel];
//以modal的方式来弹出
[self presentViewController:alert animated:YES completion:^{ }];
}else{//如果是ios7的话
if (customAlertView==nil) {
customAlertView = [[UIAlertView alloc] initWithTitle:@"xixi" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
}
[customAlertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
UITextField *nameField = [customAlertView textFieldAtIndex:0];
nameField.placeholder = @"请输入一个名称";
[customAlertView show];
}
AlertView总结区别:
iOS8的alertview在中间,而ios7的是偏上一点的.
iOS8中的alertView可以加其他的控件,但是ios7上面只能加文本输入框(两种,有密码和非密码的输入框)
但是两种方法显然还是有些不一样的.那么如果才能做得一样呢.下面提供一种思路
最好就是自定义一个UIView,然后像键盘一样隐藏在最下面,当需要弹框的时候,就直接移上来.如果需要全屏显示,而又有UINavigation的话,就可以modal一个控制器或者在window上加一个UIView[[UIApplication sharedApplication].keyWindow addSubview:<#(UIView *)view#>]
这种方式在demo中也是有的,只是做了个大概,有基础的朋友一定明白了的.
如果还有需要请到guihit上下载https://github.com/ouzhenxuan/UIAlertControllers
如果你觉得demo对你有用,请不要手下留情,拼命在guihub上点star(赞)吧.当然简书上也是很欢迎的.
圈子管家项目中用道德第三方的框架和类库
第三方框架:
AFNetworking
Bugtags
CocoaLumberjack
FMDB
HappyDNS
IQKeyboardManager
leveldb-library
Mantle
Masonry
MBProgressHUD
MJRefresh
Objective-levelDB
Pingpp
Qiniu
QRCodeReaderViewController
RPJSONValidator
SDWebImage
SSKeychain
ZXingObjC
圈子管家当中的异常提示视图
KLExceptionView这个类可以实现各种提示功能
KLExceptionView.h
typedef NS_ENUM(NSUInteger, KLExceptionViewType){
KLExceptionViewTypeNoNetWork = 1, // 无网络异常提示界面
KLExceptionViewTypeLoadFail = 2, // 网络请求失败异常提示界面
KLExceptionViewTypeNullData = 3, // 当前界面数据为空提示界面
KLExceptionViewTypeChatNotLoggedIn = 4, // 聊天列表未登录提示界面
KLExceptionViewTypeNullActivity = 5, // 商家尚未创建活动提示界面
KLExceptionViewTypeContactNotLoggedIn = 6, // 聊天未登录提示界面
KLExceptionViewTypeUserCenterNotLoggedIn = 7, // 个人中心未登录提示界面
};
@interface KLExceptionView : UIView
@property (strong, nonatomic) UIImageView *exceptionImagV;
@property (strong, nonatomic) UILabel *zhuTishiLable;
@property (strong, nonatomic) UIButton *handleBtn;
@property (assign, nonatomic) KLExceptionViewType exceptionViewType;
/// 方便整体提示层坐标浮动 适配不同屏幕需要用到
@property (strong, nonatomic) UIView * backV;
@property (copy, nonatomic) void(^handle)(void);
//- (void)showToView:(UIView *)view ExceptionViewType:(KLExceptionViewType)exceptionViewType handle:(void(^)())handle;
@end
KLExceptionView.m
import “KLExceptionView.h”
@interface KLExceptionView()
@property (strong, nonatomic) UIImage *exceptionImg;
@property (copy, nonatomic) NSString *zhuTishiStr;
@property (copy, nonatomic) NSString *buttonTitle;
@end
@implementation KLExceptionView
// 按钮回调事件
- (void)handle:(UIButton*)sender
{
if (_handle) {
self.handle();
}
}
(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
self.backgroundColor = MAIN_BG_GRAY;
_backV = [[UIView alloc]initWithFrame:CGRectZero];
_backV.backgroundColor = [UIColor clearColor];
[self addSubview:_backV];_exceptionImagV = [[UIImageView alloc] initWithFrame:CGRectZero]; [_backV addSubview:_exceptionImagV]; _zhuTishiLable = [[UILabel alloc] initWithFrame:CGRectZero]; _zhuTishiLable.backgroundColor = [UIColor clearColor]; _zhuTishiLable.textColor = HEXCOLOR(LIGHT_GRAR_COLOR);//HEXCOLOR(TAB_GRAY_COLOR); _zhuTishiLable.textAlignment = NSTextAlignmentCenter; _zhuTishiLable.font = [UIFont systemFontOfSize:13.0]; [_backV addSubview:_zhuTishiLable]; _handleBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _handleBtn.backgroundColor = [UIColor clearColor];
// _handleBtn.layer.cornerRadius = 3;
// _handleBtn.backgroundColor = HEXCOLOR(TAB_GRAY_COLOR);
[_handleBtn setTitleColor:HEXCOLOR(LIGHT_GRAR_COLOR) forState:UIControlStateNormal];
[_handleBtn setTitleColor:HEXCOLOR(LIGHT_GRAR_COLOR) forState:UIControlStateHighlighted];
[_handleBtn addTarget:self
action:@selector(handle:)
forControlEvents:UIControlEventTouchUpInside];
_handleBtn.titleLabel.font = [UIFont systemFontOfSize:13.0];
[_backV addSubview:_handleBtn];
}
return self;
}(void)layoutSubviews{
[super layoutSubviews];_backV.frame = self.bounds;
_exceptionImagV.frame = CGRectMake(0, 0, _exceptionImg.size.width, _exceptionImg.size.height);
_exceptionImagV.center = CGPointMake(_backV.width*0.5, (_backV.height *0.5-30));
_zhuTishiLable.frame = CGRectMake(0, _exceptionImagV.bottom+10, _backV.width, 16);
_handleBtn.frame = CGRectMake(0, _zhuTishiLable.bottom, 152, 16);
_handleBtn.centerX = _backV.width*0.5;
}(void)setExceptionViewType:(KLExceptionViewType)exceptionViewType{
_exceptionViewType = exceptionViewType;
switch (_exceptionViewType) {
case KLExceptionViewTypeNoNetWork:
{
self.exceptionImg = IMG_Name(@”exception_noNetWork”);
_zhuTishiStr = @”网络已断开,无法加载资源”;
_buttonTitle = @”刷新试试”;
}
break;
case KLExceptionViewTypeLoadFail:
{
self.exceptionImg = IMG_Name(@”exception_loadFail”);
_zhuTishiStr = @”好像失败了,要不要再试一次?”;
_buttonTitle = @”再试一次”;
}
break;
case KLExceptionViewTypeNullData:
{
self.exceptionImg = IMG_Name(@”exception_nullData”);
_zhuTishiStr = @”抱歉,没有找到任何资源”;
_buttonTitle = @”再试一次”;
}
break;
case KLExceptionViewTypeChatNotLoggedIn:
{
self.exceptionImg = IMG_Name(@”exception_noLogInChat”);
_zhuTishiStr = @”连个说话的都没有,不开心”;
_buttonTitle = @”点击登录”;
}
break;
case KLExceptionViewTypeNullActivity:
{
self.exceptionImg = IMG_Name(@”initialIcon”);
_zhuTishiStr = @”还没创建活动”;
_buttonTitle = @”点击右上角创建活动”;
}
break;
case KLExceptionViewTypeContactNotLoggedIn:
{
self.exceptionImg = IMG_Name(@”exception_noLogInContacts”);
_zhuTishiStr = @”一个朋友都没有,生气”;
_buttonTitle = @”点击登录”;
}
break;
case KLExceptionViewTypeUserCenterNotLoggedIn:
{
self.exceptionImg = IMG_Name(@”exception_noLogInUserCenter”);
_zhuTishiStr = @”为什么还不去登录?”;
_buttonTitle = @”点击登录”;
}
break;default: break;
}
_exceptionImagV.image = self.exceptionImg;
_zhuTishiLable.text = _zhuTishiStr;
[_handleBtn setTitle:_buttonTitle forState:UIControlStateNormal];
[_handleBtn setTitle:_buttonTitle forState:UIControlStateHighlighted];[self setNeedsLayout];
}
@end
第三方类库
分类
NSDate+Utilities
- 这里是 脚注 的 内容. ↩