[iOS微博项目 - 3.1] - 发微博界面
- 用UITextView做一个编写微博的输入框
- 没有输入任何文本的时候显示占位文本
- 统一占位文本和正文的字体
- 系统自带的输入控件有UITextField和UITextView两种
- UITextField:自带占位文本属性,不能换行
- UITextView:没有占位文本属性,能换行
- 这里我们选择UITextView进行改造
- 根据是否输入文本决定是否显示占位文本(placeholder),可能使用代理或通知机制来监听文本输入,这里我们使用通知。因为设置代理只有一个,设为view本身不合理,这样就不能设置控制器代理了。
- 在UITextView中加入一个UILabel,专门用来显示placeholder
//
// HVWComposeTextView.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/6.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <UIKit/UIKit.h> @interface HVWComposeTextView : UITextView /** placeholder 占位文本 */
@property(nonatomic, copy) NSString *placeHolder; @end //
// HVWComposeTextView.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/6.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWComposeTextView.h" @interface HVWComposeTextView() @property(nonatomic, strong) UILabel *placeHolderLabel; @end @implementation HVWComposeTextView - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; if (self) {
// 可以拖曳
self.scrollEnabled = YES;
self.alwaysBounceVertical = YES; // 添加placeHolderLabel
[self setupPlaceHolder]; // 设置默认字体
[self setFont:[UIFont systemFontOfSize:]]; // 设置通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(inputtingText) name:UITextViewTextDidChangeNotification object:self];
} return self;
} /** 添加placeHolder */
- (void) setupPlaceHolder {
UILabel *placeHolderLabel = [[UILabel alloc] init];
self.placeHolderLabel = placeHolderLabel; placeHolderLabel.textColor = [UIColor lightGrayColor];
placeHolderLabel.userInteractionEnabled = NO;
placeHolderLabel.numberOfLines = ; // 自动换行
placeHolderLabel.backgroundColor = [UIColor clearColor]; [self addSubview:placeHolderLabel];
} /** 设置子控件frame */
- (void)layoutSubviews {
[super layoutSubviews]; self.placeHolderLabel.x = ;
self.placeHolderLabel.y = ; NSMutableDictionary *attr = [NSMutableDictionary dictionary];
attr[NSFontAttributeName] = self.placeHolderLabel.font;
CGFloat placeHolderWidth = self.width - * self.placeHolderLabel.x; CGRect tempRect = [self.placeHolderLabel.text boundingRectWithSize:CGSizeMake(placeHolderWidth, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attr context:nil];
self.placeHolderLabel.size = tempRect.size;
} - (void)setPlaceHolder:(NSString *)placeHolder {
self.placeHolderLabel.text = placeHolder; // 重新计算frame,可能不会立即调用layoutSubviews
[self setNeedsLayout];
} /** 重写setFont,更改正文font的时候也更改placeHolder的font */
- (void)setFont:(UIFont *)font {
[super setFont:font];
self.placeHolderLabel.font = font; // 重新计算frame,可能不会立即调用layoutSubviews
[self setNeedsLayout];
} - (void)dealloc {
// 注销通知监听
[[NSNotificationCenter defaultCenter] removeObserver:self];
} /** 正在输入文本 */
- (void) inputtingText {
if (self.text.length) {
self.placeHolderLabel.hidden = YES;
} else {
self.placeHolderLabel.hidden = NO;
}
} @end
// HVWComposeViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. // 初始化一些功能按钮
self.title = @"发微博"; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"退出" style:UIBarButtonItemStylePlain target:self action:@selector(dismiss)]; // 添加自定义UITextView
HVWComposeTextView *composeView = [[HVWComposeTextView alloc] init];
self.composeView = composeView;
composeView.frame = self.view.bounds;
composeView.delegate = self; composeView.placeHolder = @"分享点滴精彩阿里山的会计法律考试大姐夫;拉可接受的;浪费空间阿斯顿;离开房间啊;数量的会计法律;阿克苏交电费;拉可接受的分;垃圾可适当;浪费就卡死;老地方就卡死;懒得看积分;阿里快速的减肥;拉等级考试..."; [self.view addSubview:composeView];
}
// HVWComposeViewController.m
#pragma mark - UIScrollViewDelegate
/** 开始拖曳 */
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
// 缩回键盘
[self.composeView resignFirstResponder];
}
//
// HVWComposeViewController.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/3.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWComposeViewController.h"
#import "HVWComposeTextView.h" @interface HVWComposeViewController () <UITextViewDelegate, UIScrollViewDelegate> @property(nonatomic, strong) HVWComposeTextView *composeView; @end @implementation HVWComposeViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. // 设置导航栏
[self setupNavigationBar]; // 添加自定义UITextView
[self setupTextView]; // 添加工具栏
[self setupToolBar];
} /** 设置工具栏 */
- (void) setupToolBar { } /** 设置输入控件 */
- (void) setupTextView {
HVWComposeTextView *composeView = [[HVWComposeTextView alloc] init];
self.composeView = composeView;
composeView.frame = self.view.bounds;
composeView.delegate = self; composeView.placeHolder = @"分享点滴精彩..."; [self.view addSubview:composeView];
} /** 设置导航栏 */
- (void) setupNavigationBar {
// 标题
self.title = @"发微博"; // 导航栏左方按钮
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"退出" style:UIBarButtonItemStylePlain target:self action:@selector(dismiss)];
} - (void)viewDidAppear:(BOOL)animated {
// 自动弹出键盘
[self.composeView becomeFirstResponder];
} - (void) dismiss {
[self.composeView resignFirstResponder];
[self dismissViewControllerAnimated:YES completion:nil]; } #pragma mark - UIScrollViewDelegate
/** 开始拖曳 */
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
// 缩回键盘
[self.composeView resignFirstResponder];
} @end
//
// HVWComposeToolBar.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/7.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <UIKit/UIKit.h> typedef enum {
HVWComposeToolBarButtonTagCamera, // 照相机
HVWComposeToolBarButtonTagPhotoLib, // 相册
HVWComposeToolBarButtonTagMention, // 提到@
HVWComposeToolBarButtonTagTrend, // 话题
HVWComposeToolBarButtonTagEmotion // 表情
} HVWComposeToolBarButtonTag; @class HVWComposeToolBar;
@protocol HVWComposeToolBarDelegate <NSObject> @optional
- (void) composeToolBar:(HVWComposeToolBar *) composeToolBar didButtonClicked:(HVWComposeToolBarButtonTag) tag; @end @interface HVWComposeToolBar : UIView /** 代理 */
@property(nonatomic, weak) id<HVWComposeToolBarDelegate> delegate; @end
//
// HVWComposeToolBar.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/7.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWComposeToolBar.h" @implementation HVWComposeToolBar - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; if (self) {
// 背景色
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithNamed:@"compose_toolbar_background"]]; // 添加按钮
[self addButtonWithIcon:@"compose_camerabutton_background" highlightedIcon:@"compose_camerabutton_background_highlighted" tag:HVWComposeToolBarButtonTagCamera]; [self addButtonWithIcon:@"compose_toolbar_picture" highlightedIcon:@"compose_toolbar_picture_highlighted" tag:HVWComposeToolBarButtonTagPhotoLib]; [self addButtonWithIcon:@"compose_mentionbutton_background" highlightedIcon:@"compose_mentionbutton_background_highlighted" tag:HVWComposeToolBarButtonTagMention]; [self addButtonWithIcon:@"compose_trendbutton_background" highlightedIcon:@"compose_trendbutton_background_highlighted" tag:HVWComposeToolBarButtonTagTrend]; [self addButtonWithIcon:@"compose_emoticonbutton_background" highlightedIcon:@"compose_emoticonbutton_background_highlighted" tag:HVWComposeToolBarButtonTagEmotion];
} return self;
} /** 添加一个按钮 */
- (void) addButtonWithIcon:(NSString *) icon highlightedIcon:(NSString *) highlightedIcon tag:(HVWComposeToolBarButtonTag) tag {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageWithNamed:icon] forState:UIControlStateNormal];
[button setImage:[UIImage imageWithNamed:highlightedIcon] forState:UIControlStateHighlighted];
button.tag = tag; // 按钮点击事件
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:button];
} /** 设置frame */
- (void)layoutSubviews {
[super layoutSubviews]; CGFloat buttonWidth = self.width / self.subviews.count; // 设置每个按钮
for (int i=; i<self.subviews.count; i++) {
UIButton *button = self.subviews[i]; CGFloat buttonHeight = buttonWidth;
CGFloat buttonX = i * buttonWidth;
CGFloat buttonY = (self.height - buttonHeight) * 0.5;
button.frame = CGRectMake(buttonX, buttonY, buttonWidth, buttonHeight);
}
} /** 按钮点击 */
- (void) buttonClicked:(UIButton *) button {
// 通知代理
if ([self.delegate respondsToSelector:@selector(composeToolBar:didButtonClicked:)]) {
[self.delegate composeToolBar:self didButtonClicked:button.tag];
}
} @end
// HVWComposeViewController.m
/** 设置工具栏 */
- (void) setupToolBar {
HVWComposeToolBar *toolBar = [[HVWComposeToolBar alloc] init];
toolBar.width = self.view.width;
toolBar.height = ;
toolBar.delegate = self; self.composeView.inputAccessoryView = toolBar;
}
// HVWComposeViewController.m
/** 设置工具栏 */
- (void) setupToolBar {
HVWComposeToolBar *toolBar = [[HVWComposeToolBar alloc] init];
self.toolBar = toolBar;
toolBar.width = self.view.width;
toolBar.height = ;
toolBar.delegate = self; toolBar.x = ;
// 在底部显示
toolBar.y = self.view.height - toolBar.height; [self.view addSubview:toolBar];
} /** 设置输入控件 */
- (void) setupTextView {
HVWComposeTextView *composeView = [[HVWComposeTextView alloc] init];
self.composeView = composeView;
composeView.frame = self.view.bounds;
composeView.delegate = self; composeView.placeHolder = @"分享点滴精彩..."; [self.view addSubview:composeView]; // 监听键盘通知
// 键盘将弹出
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; // 键盘将缩回
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; // 添加图片显示区
[self setupImageDisplayView];
} #pragma mark - 键盘通知处理
/** 键盘将弹出 */
- (void) keyboardWillShow:(NSNotification *) note {
// 键盘弹出需要时间
CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // 移动工具条
[UIView animateWithDuration:duration animations:^{
// 获取键盘高度
CGRect keyboardFrame = [note.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGFloat keyboardHeight = keyboardFrame.size.height; self.toolBar.transform = CGAffineTransformMakeTranslation(, - * keyboardHeight);
}];
} /** 键盘将缩回 */
- (void) keyboardWillHide:(NSNotification *) note {
// 键盘缩回需要时间
CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // 移动工具条
[UIView animateWithDuration:duration animations:^{
self.toolBar.transform = CGAffineTransformIdentity;
}];
}
//
// HVWComposeImageDisplayView.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/7.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <UIKit/UIKit.h> @interface HVWComposeImageDisplayView : UIView - (void) addImage:(UIImage *) image; @end
//
// HVWComposeImageDisplayView.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/7.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWComposeImageDisplayView.h" #define MaxColumn 4 @implementation HVWComposeImageDisplayView /** 添加图片 */
- (void) addImage:(UIImage *) image {
HVWLog(@"addImage");
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.contentMode = UIViewContentModeScaleAspectFit; [self addSubview:imageView]; [self setNeedsDisplay];
} /** 设置frame */
- (void)layoutSubviews {
[super layoutSubviews]; UIImageView *imageView = [self.subviews lastObject];
int index = self.subviews.count - ;
// 所在列
int column = index % MaxColumn;
// 所在行
int row = index / MaxColumn; CGFloat margin = ;
CGFloat imageWidth = (self.width - (MaxColumn + ) * margin) / MaxColumn;
CGFloat imageHeight = imageWidth;
CGFloat imageX = column * (imageWidth + margin) + margin;
CGFloat imageY = row * (imageHeight + margin); imageView.frame = CGRectMake(imageX, imageY, imageWidth, imageHeight);
} @end
//
// HVWComposeViewController.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/3.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWComposeViewController.h"
#import "HVWComposeTextView.h"
#import "HVWComposeToolBar.h"
#import "HVWComposeImageDisplayView.h" @interface HVWComposeViewController () <UITextViewDelegate, UIScrollViewDelegate, HVWComposeToolBarDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate> /** 输入框 */
@property(nonatomic, strong) HVWComposeTextView *composeView; /** 工具条 */
@property(nonatomic, strong) HVWComposeToolBar *toolBar; /** 图片显示区 */
@property(nonatomic, strong) HVWComposeImageDisplayView *imageDisplayView; @end @implementation HVWComposeViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. // 设置导航栏
[self setupNavigationBar]; // 添加自定义UITextView
[self setupTextView]; // 添加工具栏
[self setupToolBar];
} /** 设置工具栏 */
- (void) setupToolBar {
HVWComposeToolBar *toolBar = [[HVWComposeToolBar alloc] init];
self.toolBar = toolBar;
toolBar.width = self.view.width;
toolBar.height = ;
toolBar.delegate = self; toolBar.x = ;
// 在底部显示
toolBar.y = self.view.height - toolBar.height; [self.view addSubview:toolBar];
} /** 设置输入控件 */
- (void) setupTextView {
HVWComposeTextView *composeView = [[HVWComposeTextView alloc] init];
self.composeView = composeView;
composeView.frame = self.view.bounds;
composeView.delegate = self; composeView.placeHolder = @"分享点滴精彩..."; [self.view addSubview:composeView]; // 监听键盘通知
// 键盘将弹出
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; // 键盘将缩回
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; // 添加图片显示区
[self setupImageDisplayView];
} /** 设置导航栏 */
- (void) setupNavigationBar {
// 标题
self.title = @"发微博"; // 导航栏左方按钮
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"退出" style:UIBarButtonItemStylePlain target:self action:@selector(dismiss)];
} /** 添加图片显示区 */
- (void) setupImageDisplayView {
HVWComposeImageDisplayView *imageDisplayView = [[HVWComposeImageDisplayView alloc] init];
imageDisplayView.size = self.composeView.size;
imageDisplayView.x = ;
imageDisplayView.y = ; self.imageDisplayView = imageDisplayView; [self.composeView addSubview:imageDisplayView];
} - (void)viewDidAppear:(BOOL)animated {
// 自动弹出键盘
[self.composeView becomeFirstResponder];
} - (void) dismiss {
[self.composeView resignFirstResponder];
[self dismissViewControllerAnimated:YES completion:nil]; } #pragma mark - UIScrollViewDelegate
/** 开始拖曳 */
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
// 缩回键盘
[self.composeView resignFirstResponder];
} #pragma mark - HVWComposeToolBarDelegate
/** 工具栏的按钮被点击了 */
- (void)composeToolBar:(HVWComposeToolBar *)composeToolBar didButtonClicked:(HVWComposeToolBarButtonTag)tag {
// 判断哪个按钮被点击
switch (tag) {
case HVWComposeToolBarButtonTagCamera: // 相机
[self openCamera];
break;
case HVWComposeToolBarButtonTagPhotoLib: // 相册
[self openAlbum];
break;
case HVWComposeToolBarButtonTagMention: // 提到@ break;
case HVWComposeToolBarButtonTagTrend: // 话题 break;
case HVWComposeToolBarButtonTagEmotion: // 表情 break;
default:
break;
}
} /** 打开相机 */
- (void) openCamera {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self; [self presentViewController:picker animated:YES completion:nil];
} /** 打开相册 */
- (void) openAlbum {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self; [self presentViewController:picker animated:YES completion:nil];
} #pragma mark - UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// 取得原图
UIImage *image = info[UIImagePickerControllerOriginalImage];
[self.imageDisplayView addImage:image]; [picker dismissViewControllerAnimated:YES completion:nil];
} #pragma mark - 键盘通知处理
/** 键盘将弹出 */
- (void) keyboardWillShow:(NSNotification *) note {
// 键盘弹出需要时间
CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // 移动工具条
[UIView animateWithDuration:duration animations:^{
// 获取键盘高度
CGRect keyboardFrame = [note.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGFloat keyboardHeight = keyboardFrame.size.height; self.toolBar.transform = CGAffineTransformMakeTranslation(, - * keyboardHeight);
}];
} /** 键盘将缩回 */
- (void) keyboardWillHide:(NSNotification *) note {
// 键盘缩回需要时间
CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // 移动工具条
[UIView animateWithDuration:duration animations:^{
self.toolBar.transform = CGAffineTransformIdentity;
}];
} @end
[iOS微博项目 - 3.1] - 发微博界面的更多相关文章
- [iOS微博项目 - 3.2] - 发送微博
github: https://github.com/hellovoidworld/HVWWeibo A.使用微博API发送微博 1.需求 学习发送微博API 发送文字微博 发送带有图片的微博 ...
- [iOS微博项目 - 4.0] - 自定义微博cell
github: https://github.com/hellovoidworld/HVWWeibo A.自定义微博cell基本结构 1.需求 创建自定义cell的雏形 cell包含:内容.工具条 内 ...
- [iOS微博项目 - 2.6] - 获取微博数据
github: https://github.com/hellovoidworld/HVWWeibo A.新浪获取微博API 1.读取微博API 2.“statuses/home_time ...
- AJ学IOS 之微博项目实战(13)发送微博调用相机里面的图片以及调用相机
AJ分享,必须精品 一:效果 二:代码 相机部分就简单多了,几行代码调用而已,但是如果你要是想实现更多丰富的功能,需要自己写.利用AssetsLibrary.framework,利用这个框架可以获得手 ...
- AJ学IOS 之微博项目实战(12)发送微博自定义工具条代理实现点击事件
AJ分享,必须精品 一:效果 二:封装好的工具条 NYComposeToolbar.h 带代理方法 #import <UIKit/UIKit.h> typedef enum { NYCom ...
- AJ学IOS 之微博项目实战(11)发送微博自定义TextView实现带占位文字
AJ分享,必须精品 一:效果 二:代码: 由于系统自带的UITextField:和UITextView:不能满足我们的需求,所以我们需要自己设计一个. UITextField: 1.文字永远是一行,不 ...
- iOS开发——项目需求-快速回到当前界面的顶部
利用UIWindow实现快速到达顶部 如下图,在状态栏添加一个没有颜色的UIWindow(里面添加一个按钮),实现点击这个按钮时能快速的回到当前界面的顶部 核心代码 一.利用UIWindow实现到达顶 ...
- [iOS微博项目 - 1.6] - 自定义TabBar
A.自定义TabBar 1.需求 控制TabBar内的item的文本颜色(普通状态.被选中状态要和图标一致).背景(普通状态.被选中状态均为透明) 重新设置TabBar内的item位置,为下一步在Ta ...
- AJ学IOS 之微博项目实战(1)微博主框架-子控制器的添加
AJ分享,必须精品 一:简单介绍 这是新浪微博的iOS端项目,来自于黑马的一个实战项目. 主要分成五大模块,本次全部运用纯代码实现,其中会用到很多前面学过得内容,如果有的地方有重复的知识点,说明这个知 ...
随机推荐
- mysql笔记(前面自己写的不标准有些地方)
day15-MySQL 数据库 1 数据库概念(了解) 1.1 什么是数据库 数据库就是用来存储和管理数据的仓库! 数据库存储数据的优先: l 可存储大量数据: l 方便检索: l 保持数据的一 ...
- 甚是挂念学校的acmer
虽然自己一直不承认.. 今天头疼,不想工作,况且自己服务端代码也写差不多了,于是又干起了自己的本行,去信息站找退役帖看,又把3xian的文章看了一遍,这次我从文章里面读到的更多的是懊恼,恨铁不成钢.经 ...
- LA 3882 And Then There Was One
解题思路:分析要好久,懒得分析了,贴了某大牛的的分析,代码就是我自己写的. N个数排成一圈,第一次删除m,以后每k个数删除一次,求最后一被删除的数. 如果这题用链表或者数组模拟整个过程的话,时间复杂度 ...
- web.xml 中的listener、 filter、servlet 加载顺序
在项目中总会遇到一些关于加载的优先级问题,近期也同样遇到过类似的,所以自己查找资料总结了下,下面有些是转载其他人的,毕竟人家写的不错,自己也就不重复造轮子了,只是略加点了自己的修饰. 首先可以肯定的是 ...
- CentOS 安装BitTorrent Sync详细步骤
官网:https://www.getsync.com 这个软件安装完后通过网页浏览器设置共享目录并生成同步Secret,异地的客户端可以通过这个同步Secret访问共的目录,其中有读写和只读两种同步方 ...
- Android下Fragment的动画切换效果
效果图如下: 源码链接 : 请戳这里
- ueditor-百度编辑器插件
1.官网地址:http://ueditor.baidu.com/website/index.html 2.定制化工具栏:(1)修改ueditor.config.js的toolsbar(2)在创建编辑器 ...
- Effective java笔记6--异常
充分发挥异常的优点,可以提高一个程序的可读性.可靠性和可维护性.如果使用不当的话,它们也会带来负面影响. 一.只针对不正常的条件才使用异常 先看一段代码: //Horrible abuse of ex ...
- 关于python中的unicode字符串的使用
基于python2.7中的字符串: unicode-->编码encode('utf-8')-->写入文件 读出文件-->解码decode('utf-8')-->unicode ...
- extern "c" 的作用
作用:实现C和C++混合编程. 原理:C和C++编译器编译之后,函数名会编译成不同的名字,链接阶段名字查找会找不到目标,后面实例中会详解. 用法:①.c文件中定义的函数,.cpp文件要调用时,该.cp ...