1、创建BIDTinyPixDocument类

 #import <UIKit/UIKit.h>

 //创建文档类
@interface TinyPixDocument : UIDocument
//接收一对行和列索引作为参数
- (BOOL)stateAtRow:(NSUInteger)row column:(NSUInteger)column;
//指定的行和列设置特定的状态
- (void)setState:(BOOL)state atRow:(NSUInteger)row column:(NSUInteger)column;
//负责切换特定位置处的状态
- (void)toggleStateAtRow:(NSUInteger)row column:(NSUInteger)column; @end
 #import "TinyPixDocument.h"

 //类扩展
@interface TinyPixDocument ()
@property (nonatomic,strong) NSMutableData * bitmap;
@end @implementation TinyPixDocument //将每个位图初始化为从一个角延伸到另一个角的对角线图案。
- (id)initWithFileURL:(NSURL *)url
{
self = [super initWithFileURL:url];
if (self) {
unsigned char startPattern[] = {
0x01,
0x02,
0x04,
0x08,
0x10,
0x20,
0x40,
0x80
}; self.bitmap = [NSMutableData dataWithBytes:startPattern length:];
}
return self;
} //实现读取单个位的状态的方法。实现这个方法只要从字节数组中获取相关字节,然后对其进行位移操作和AND操作,检查是否设置了给定位,相应的返回YES或NO。
- (BOOL)stateAtRow:(NSUInteger)row column:(NSUInteger)column
{
const char * bitmapBytes = [self.bitmap bytes];
char rowByte = bitmapBytes[row];
char result = ( << column) & rowByte;
if (result != ) {
return YES;
} else {
return NO;
}
}
//这个方法正好和上一个相反,用于为给定行和列的位置设置值。
- (void)setState:(BOOL)state atRow:(NSUInteger)row column:(NSUInteger)column
{
char *bitmapBytes = [self.bitmap mutableBytes];
char *rowByte = &bitmapBytes[row]; if (state) {
*rowByte = *rowByte | ( << column);
} else {
*rowByte = *rowByte & ~( << column);
}
}
//辅助方法,外部代码使用该方法来切换单个单元的状态。
- (void)toggleStateAtRow:(NSUInteger)row column:(NSUInteger)column
{
BOOL state = [self stateAtRow:row column:column];
[self setState:!state atRow:row column:column];
} //保存文档时调用
- (id)contentsForType:(NSString *)typeName error:(NSError **)outError
{
NSLog(@"saving document to URL %@", self.fileURL);
return [self.bitmap copy];
}
//系统从存储区加载了数据,并且准备将这个数据提供给文档类的一个实例时,调用此方法。
- (BOOL)loadFromContents:(id)contents ofType:(NSString *)typeName
error:(NSError **)outError
{
NSLog(@"loading document from URL %@", self.fileURL);
self.bitmap = [contents mutableCopy];
return true;
}

2、主控制器代码

 #import "BIDMasterViewController.h"
#import "BIDDetailViewController.h"
#import "BIDTinyPixDocument.h" @interface BIDMasterViewController () <UIAlertViewDelegate> @property (weak, nonatomic) IBOutlet UISegmentedControl *colorControl;
@property (strong, nonatomic) NSArray * documentFilenames;
@property (strong, nonatomic) BIDTinyPixDocument * chosenDocument; @property (strong, nonatomic) NSMetadataQuery * query;
@property (strong, nonatomic) NSMutableArray * documentURLs; @end @implementation BIDMasterViewController /* original
//接收一个文件名作为参数,将它和应用的Document目录的文件路径结合起来,然后返回一个指向该文件的URL指针。
- (NSURL *)urlForFilename:(NSString *)filename {
NSFileManager * fm = [NSFileManager defaultManager];
NSArray * urls = [fm URLsForDirectory:NSDocumentDirectory
inDomains:NSUserDomainMask];
NSURL * directoryURL = urls[0];
NSURL * fileURL = [directoryURL URLByAppendingPathComponent:filename];
return fileURL;
}
*/ - (NSURL *)urlForFilename:(NSString *)filename
{
// be sure to insert "Documents" into the path
NSURL * baseURL = [[NSFileManager defaultManager]
URLForUbiquityContainerIdentifier:nil];
NSURL * pathURL = [baseURL URLByAppendingPathComponent:@"Documents"];
NSURL * destinationURL = [pathURL URLByAppendingPathComponent:filename];
return destinationURL;
} /* original //也用到了Document目录,用于查找代表现存文档的文件。该方法获取它所找到的文件,并将它们根据创建的时间来排序,以便用户可以以“博客风格”的顺序来查看文档列表(第一个文档是最新的)。文档文件名被存放在documentFilenames属性中,然后重新加载表视图(我们尚未处理)。
- (void)reloadFiles {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *path = paths[0];
NSFileManager *fm = [NSFileManager defaultManager]; NSError *dirError;
NSArray *files = [fm contentsOfDirectoryAtPath:path error:&dirError];
if (!files) {
NSLog(@"Encountered error while trying to list files in directory %@: %@",
path, dirError);
}
NSLog(@"found files: %@", files); files = [files sortedArrayUsingComparator:
^NSComparisonResult(id filename1, id filename2) {
NSDictionary *attr1 = [fm attributesOfItemAtPath:
[path stringByAppendingPathComponent:filename1]
error:nil];
NSDictionary *attr2 = [fm attributesOfItemAtPath:
[path stringByAppendingPathComponent:filename2]
error:nil];
return [attr2[NSFileCreationDate] compare: attr1[NSFileCreationDate]];
}];
self.documentFilenames = files;
[self.tableView reloadData];
}
*/ - (void)reloadFiles {
NSFileManager * fileManager = [NSFileManager defaultManager];
// passing nil is OK here, matches first entitlement
NSURL * cloudURL = [fileManager URLForUbiquityContainerIdentifier:nil];
NSLog(@"got cloudURL %@", cloudURL); // returns nil in simulator self.query = [[NSMetadataQuery alloc] init];
_query.predicate = [NSPredicate predicateWithFormat:@"%K like '*.tinypix'",
NSMetadataItemFSNameKey];
_query.searchScopes = [NSArray arrayWithObject:
NSMetadataQueryUbiquitousDocumentsScope];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(updateUbiquitousDocuments:)
name:NSMetadataQueryDidFinishGatheringNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(updateUbiquitousDocuments:)
name:NSMetadataQueryDidUpdateNotification
object:nil];
[_query startQuery];
} - (void)updateUbiquitousDocuments:(NSNotification *)notification {
self.documentURLs = [NSMutableArray array];
self.documentFilenames = [NSMutableArray array]; NSLog(@"updateUbiquitousDocuments, results = %@", self.query.results);
NSArray *results = [self.query.results sortedArrayUsingComparator:
^NSComparisonResult(id obj1, id obj2) {
NSMetadataItem *item1 = obj1;
NSMetadataItem *item2 = obj2;
return [[item2 valueForAttribute:NSMetadataItemFSCreationDateKey] compare:
[item1 valueForAttribute:NSMetadataItemFSCreationDateKey]];
}]; for (NSMetadataItem *item in results) {
NSURL *url = [item valueForAttribute:NSMetadataItemURLKey];
[self.documentURLs addObject:url];
[(NSMutableArray *)_documentFilenames addObject:[url lastPathComponent]];
} [self.tableView reloadData];
} - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return ;
} - (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return [self.documentFilenames count];
} - (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FileCell"]; NSString * path = self.documentFilenames[indexPath.row];
cell.textLabel.text = path.lastPathComponent.stringByDeletingPathExtension;
return cell;
} - (IBAction)chooseColor:(id)sender {
NSInteger selectedColorIndex = [(UISegmentedControl *)sender selectedSegmentIndex];
[self setTintColorForIndex:selectedColorIndex]; // NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// [prefs setInteger:selectedColorIndex forKey:@"selectedColorIndex"];
// [prefs synchronize]; NSUbiquitousKeyValueStore * prefs = [NSUbiquitousKeyValueStore defaultStore];
[prefs setLongLong:selectedColorIndex forKey:@"selectedColorIndex"];
} - (void)setTintColorForIndex:(NSInteger)selectedColorIndex {
UIColor *tint = nil;
switch (selectedColorIndex) {
case :
tint = [UIColor redColor];
break;
case :
tint = [UIColor colorWithRed: green:0.6 blue: alpha:];
break;
case :
tint = [UIColor blueColor];
break;
default:
break;
}
[UIApplication sharedApplication].keyWindow.tintColor = tint;
} - (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated]; // NSUserDefaults * prefs = [NSUserDefaults standardUserDefaults];
// NSInteger selectedColorIndex = [prefs integerForKey:@"selectedColorIndex"]; NSUbiquitousKeyValueStore * prefs = [NSUbiquitousKeyValueStore defaultStore];
NSInteger selectedColorIndex = (int)[prefs longLongForKey:@"selectedColorIndex"]; [self setTintColorForIndex:selectedColorIndex];
[self.colorControl setSelectedSegmentIndex:selectedColorIndex];
} - (void)viewDidLoad
{
[super viewDidLoad]; UIBarButtonItem * addButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self
action:@selector(insertNewObject)];
self.navigationItem.rightBarButtonItem = addButton;
[self reloadFiles];
} - (void)insertNewObject {
// get the name
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle:@"Filename"
message:@"Enter a name for your new TinyPix document."
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Create", nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert show];
} - (void)alertView:(UIAlertView *)alertView
didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == ) {
NSString *filename = [NSString stringWithFormat:@"%@.tinypix",
[alertView textFieldAtIndex:].text];
NSURL *saveUrl = [self urlForFilename:filename];
self.chosenDocument = [[BIDTinyPixDocument alloc] initWithFileURL:saveUrl];
[self.chosenDocument saveToURL:saveUrl
forSaveOperation:UIDocumentSaveForCreating
completionHandler:^(BOOL success) {
if (success) {
NSLog(@"save OK");
[self reloadFiles];
[self performSegueWithIdentifier:@"masterToDetail"
sender:self];
} else {
NSLog(@"failed to save!");
}
}];
}
} - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if (sender == self) {
// if sender == self, a new document has just been created,
// and chosenDocument is already set. UIViewController * destination = segue.destinationViewController;
if ([destination respondsToSelector:@selector(setDetailItem:)]) {
[destination setValue:self.chosenDocument forKey:@"detailItem"];
}
} else {
// find the chosen document from the tableview
NSIndexPath * indexPath = [self.tableView indexPathForSelectedRow];
NSString * filename = self.documentFilenames[indexPath.row];
NSURL * docUrl = [self urlForFilename:filename];
self.chosenDocument = [[BIDTinyPixDocument alloc] initWithFileURL:docUrl];
[self.chosenDocument openWithCompletionHandler:^(BOOL success) {
if (success) {
NSLog(@"load OK");
UIViewController *destination = segue.destinationViewController;
if ([destination respondsToSelector:@selector(setDetailItem:)]) {
[destination setValue:self.chosenDocument forKey:@"detailItem"];
}
} else {
NSLog(@"failed to load!");
}
}];
}
}

3、创建BIDTinyPixView视图类,用于显示用户可编辑的网格。

 #import <UIKit/UIKit.h>
@class BIDTinyPixDocument; @interface BIDTinyPixView : UIView
@property (strong, nonatomic) BIDTinyPixDocument * document;
@end
 #import "BIDTinyPixView.h"
#import "BIDTinyPixDocument.h" typedef struct {
NSUInteger row;
NSUInteger column;
} GridIndex; @interface BIDTinyPixView () @property (assign, nonatomic) CGSize blockSize;
@property (assign, nonatomic) CGSize gapSize;
@property (assign, nonatomic) GridIndex selectedBlockIndex; @end @implementation BIDTinyPixView - (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self commonInit];
}
return self;
} - (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self commonInit];
}
return self;
} - (void)commonInit{
_blockSize = CGSizeMake(, );
_gapSize = CGSizeMake(, );
_selectedBlockIndex.row = NSNotFound;
_selectedBlockIndex.column = NSNotFound;
} // Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
if (!_document) return; for (NSUInteger row = ; row < ; row++) {
for (NSUInteger column = ; column < ; column++) {
[self drawBlockAtRow:row column:column];
}
}
} - (void)drawBlockAtRow:(NSUInteger)row column:(NSUInteger)column {
CGFloat startX = (_blockSize.width + _gapSize.width) * ( - column) + ;
CGFloat startY = (_blockSize.height + _gapSize.height) * row + ;
CGRect blockFrame = CGRectMake(startX, startY, _blockSize.width, _blockSize.height);
UIColor *color = [_document stateAtRow:row column:column] ?
[UIColor blackColor] : [UIColor whiteColor];
[color setFill];
[self.tintColor setStroke];
UIBezierPath *path = [UIBezierPath bezierPathWithRect:blockFrame];
[path fill];
[path stroke];
} - (GridIndex)touchedGridIndexFromTouches:(NSSet *)touches {
GridIndex result;
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self];
result.column = - (location.x * 8.0 / self.bounds.size.width);
result.row = location.y * 8.0 / self.bounds.size.height;
return result;
} - (void)toggleSelectedBlock {
[_document toggleStateAtRow:_selectedBlockIndex.row
column:_selectedBlockIndex.column];
[[_document.undoManager prepareWithInvocationTarget:_document]
toggleStateAtRow:_selectedBlockIndex.row column:_selectedBlockIndex.column];
[self setNeedsDisplay];
} - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
self.selectedBlockIndex = [self touchedGridIndexFromTouches:touches];
[self toggleSelectedBlock];
} - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
GridIndex touched = [self touchedGridIndexFromTouches:touches];
if (touched.row != _selectedBlockIndex.row
|| touched.column != _selectedBlockIndex.column) {
_selectedBlockIndex = touched;
[self toggleSelectedBlock];
}
}

4、添加BIDDetailViewController内容

 @interface BIDDetailViewController : UIViewController

 @property (strong, nonatomic) id detailItem;

 @end
 #import "BIDDetailViewController.h"
#import "BIDTinyPixView.h" @interface BIDDetailViewController ()
@property (weak, nonatomic) IBOutlet BIDTinyPixView *pixView;
- (void)configureView;
@end @implementation BIDDetailViewController #pragma mark - Managing the detail item - (void)setDetailItem:(id)newDetailItem
{
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem; // Update the view.
[self configureView];
}
} - (void)configureView
{
// Update the user interface for the detail item. if (self.detailItem) {
self.pixView.document = self.detailItem;
[self.pixView setNeedsDisplay];
}
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self configureView];
}
//当用户按下返回按钮回到主列表时,文档实例将在没有进行任何保存操作的情况下被销毁,所以添加如下方法。
  //一旦用户离开详情页面,就关闭文档,关闭文档会导致该文档被自动保存,保存工作发生在后台线程中。
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
UIDocument * doc = self.detailItem;
[doc closeWithCompletionHandler:nil];
}

5、添加iCloud支持

创建授权文件

6、如何查询

@property (strong, nonatomic) NSMetadataQuery * query;
@property (strong, nonatomic) NSMutableArray * documentURLs; - (void)reloadFiles {
NSFileManager * fileManager = [NSFileManager defaultManager];
// passing nil is OK here, matches first entitlement
NSURL * cloudURL = [fileManager URLForUbiquityContainerIdentifier:nil];
NSLog(@"got cloudURL %@", cloudURL); // returns nil in simulator self.query = [[NSMetadataQuery alloc] init];
_query.predicate = [NSPredicate predicateWithFormat:@"%K like '*.tinypix'",
NSMetadataItemFSNameKey];
_query.searchScopes = [NSArray arrayWithObject:
NSMetadataQueryUbiquitousDocumentsScope];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(updateUbiquitousDocuments:)
name:NSMetadataQueryDidFinishGatheringNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(updateUbiquitousDocuments:)
name:NSMetadataQueryDidUpdateNotification
object:nil];
[_query startQuery];
} //实现查询完成时的那些通知
//查询的结果包含在一个NSMetadataItem对象的列表,从中我们可以获取文件URL和创建日期等数据项,我们根据创建日期来排列这些项,然后获取所有的URL以供之后使用。
- (void)updateUbiquitousDocuments:(NSNotification *)notification {
self.documentURLs = [NSMutableArray array];
self.documentFilenames = [NSMutableArray array]; NSLog(@"updateUbiquitousDocuments, results = %@", self.query.results);
NSArray *results = [self.query.results sortedArrayUsingComparator:
^NSComparisonResult(id obj1, id obj2) {
NSMetadataItem *item1 = obj1;
NSMetadataItem *item2 = obj2;
return [[item2 valueForAttribute:NSMetadataItemFSCreationDateKey] compare:
[item1 valueForAttribute:NSMetadataItemFSCreationDateKey]];
}]; for (NSMetadataItem *item in results) {
NSURL *url = [item valueForAttribute:NSMetadataItemURLKey];
[self.documentURLs addObject:url];
[(NSMutableArray *)_documentFilenames addObject:[url lastPathComponent]];
} [self.tableView reloadData];
}

7、保存到哪里

 - (NSURL *)urlForFilename:(NSString *)filename
{
// be sure to insert "Documents" into the path
NSURL * baseURL = [[NSFileManager defaultManager]
URLForUbiquityContainerIdentifier:nil];
NSURL * pathURL = [baseURL URLByAppendingPathComponent:@"Documents"];
NSURL * destinationURL = [pathURL URLByAppendingPathComponent:filename];
return destinationURL;
}

8、将首选项保存到iCloud

 - (IBAction)chooseColor:(id)sender {
NSInteger selectedColorIndex = [(UISegmentedControl *)sender selectedSegmentIndex];
[self setTintColorForIndex:selectedColorIndex]; // NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// [prefs setInteger:selectedColorIndex forKey:@"selectedColorIndex"];
// [prefs synchronize]; NSUbiquitousKeyValueStore * prefs = [NSUbiquitousKeyValueStore defaultStore];
[prefs setLongLong:selectedColorIndex forKey:@"selectedColorIndex"];
}
 - (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated]; // NSUserDefaults * prefs = [NSUserDefaults standardUserDefaults];
// NSInteger selectedColorIndex = [prefs integerForKey:@"selectedColorIndex"]; NSUbiquitousKeyValueStore * prefs = [NSUbiquitousKeyValueStore defaultStore];
NSInteger selectedColorIndex = (int)[prefs longLongForKey:@"selectedColorIndex"];

[self setTintColorForIndex:selectedColorIndex];
[self.colorControl setSelectedSegmentIndex:selectedColorIndex];
}

iCloud之旅的更多相关文章

  1. 精通iOS开发(第5版)

    <精通iOS开发(第5版)> 基本信息 原书名:Beginning ios 6 development:exploring the ios sdk 作者: (美)David Mark   ...

  2. Linq之旅:Linq入门详解(Linq to Objects)

    示例代码下载:Linq之旅:Linq入门详解(Linq to Objects) 本博文详细介绍 .NET 3.5 中引入的重要功能:Language Integrated Query(LINQ,语言集 ...

  3. WCF学习之旅—第三个示例之四(三十)

           上接WCF学习之旅—第三个示例之一(二十七)               WCF学习之旅—第三个示例之二(二十八)              WCF学习之旅—第三个示例之三(二十九)   ...

  4. 【C#代码实战】群蚁算法理论与实践全攻略——旅行商等路径优化问题的新方法

    若干年前读研的时候,学院有一个教授,专门做群蚁算法的,很厉害,偶尔了解了一点点.感觉也是生物智能的一个体现,和遗传算法.神经网络有异曲同工之妙.只不过当时没有实际需求学习,所以没去研究.最近有一个这样 ...

  5. Hadoop学习之旅二:HDFS

    本文基于Hadoop1.X 概述 分布式文件系统主要用来解决如下几个问题: 读写大文件 加速运算 对于某些体积巨大的文件,比如其大小超过了计算机文件系统所能存放的最大限制或者是其大小甚至超过了计算机整 ...

  6. .NET跨平台之旅:在生产环境中上线第一个运行于Linux上的ASP.NET Core站点

    2016年7月10日,我们在生产环境中上线了第一个运行于Linux上的ASP.NET Core站点,这是一个简单的提供后端服务的ASP.NET Core Web API站点. 项目是在Windows上 ...

  7. 【Knockout.js 学习体验之旅】(3)模板绑定

    本文是[Knockout.js 学习体验之旅]系列文章的第3篇,所有demo均基于目前knockout.js的最新版本(3.4.0).小茄才识有限,文中若有不当之处,还望大家指出. 目录: [Knoc ...

  8. 【Knockout.js 学习体验之旅】(2)花式捆绑

    本文是[Knockout.js 学习体验之旅]系列文章的第2篇,所有demo均基于目前knockout.js的最新版本(3.4.0).小茄才识有限,文中若有不当之处,还望大家指出. 目录: [Knoc ...

  9. 【Knockout.js 学习体验之旅】(1)ko初体验

    前言 什么,你现在还在看knockout.js?这货都已经落后主流一千年了!赶紧去学Angular.React啊,再不赶紧的话,他们也要变out了哦.身旁的90后小伙伴,嘴里还塞着山东的狗不理大蒜包, ...

随机推荐

  1. DOM笔记(四):HTML 5 DOM复杂数据类型

    HTML 5 DOM定义了一下集合.列表等复杂的数据类型用于实现便捷的操作.相对于HTML 4 DOM,HTML 5 DOM增加了HTMLCollection.DOMTokenList.DOMStri ...

  2. Python 学习笔记(三)Function

    python引用变量的顺序: 当前作用域局部变量->外层作用域变量->当前模块中的全局变量->python内置变量 1. Scope: • If a variable is assi ...

  3. java集合框架1

    1.综述 所有集合类都位于java.util包下.集合中只能保存对象(保存对象的引用变量).(数组既可以保存基本类型的数据也可以保存对象). 当我们把一个对象放入集合中后,系统会把所有集合元素都当成O ...

  4. UVALive 7454 Parentheses (栈+模拟)

    Parentheses 题目链接: http://acm.hust.edu.cn/vjudge/contest/127401#problem/A Description http://7xjob4.c ...

  5. CF#190DIV.1

    /* CF#190DIV.1-C 题意:给你n个结点的树,给这些结点标记字母AB..Z,对于标记相同的结点路径上 的结点的标记必须有一个是大于该标记的:问是否可以标记(A是最大标记) 分析:整天思路就 ...

  6. [iOS基础控件 - 6.12.2] Modal

    A.概念 1.也可以用来切换控制器 2.如ActionSheet   除了push之外,还有另外一种控制器的切换方式,那就是Modal 任何控制器都能通过Modal的形式展示出来 Modal的默认效果 ...

  7. HTTP协议状态码详解

    HTTP状态码,我都是现查现用. 我以前记得几个常用的状态码,比如200,302,304,404, 503. 一般来说我也只需要了解这些常用的状态码就可以了.  如果是做AJAX,REST,网络爬虫, ...

  8. 关于名称重整(name mangling)、多态性的一些简单介绍

    在看GCC源码的时候看到mangles这个单词,于是google了一下. 在面向对象编程语言出现之前,如果你想要打印不同类型的数据,需要写多个方法,例如PrintInteger(int i),Prin ...

  9. Ubuntu12.04 使用中遇到的问题

    这个随笔回记录使用Ubuntu遇到的一些问题   不定期进行整理和分类 1.Question:   ubuntu 无法检测包或者源码包 Description:Ubuntu软件中心打开时报错  无法检 ...

  10. Listener 监听器

    Listener的定义与作用 监听器Listener就是在application,session,request三个对象创建.销毁或者往其中添加修改删除属性时自动执行代码的功能组件. Listener ...