今天了解到了双拼输入法。其原理并不复杂,就是将汉语拼音的声母和韵母拆分开来,例如:“双” – shuang – sh & uang。大部分字母(按键)本身就是声母,然后每个按键被分配一些韵母。这样一来,任何汉字都可以通过敲击两次按键被打出。对比全拼输入法,双拼输入法的效率更高。例如,“双” – 如果用全拼输入法需要敲击键盘六次,如果用双拼输入法则只需要敲击两次。

双拼输入法有多种方案,如微软、小鹤、自然码,等等。其之间的区别就是声母韵母的按键编排不一样。经过简单调查,发现小鹤的按键编排似乎更加合理,所以我选择了小鹤作为我的入门双拼输入法。

其实上手双拼也不难,只需要记住韵母的位置就好。打字的时候把编排表放在旁边,记不住的时候看一眼,大概几个小时就可以基本掌握双拼。这篇博客就是我用双拼打出来的。虽然刚开始会有些不适应,但熟练后打字效率便会大大提高。

This blog will mainly cover some iOS development details during my build of Meme2.0 App.


First off, it’s the UICollectionView. UICollectionView is very similar to UITableView, the most important three methods are numberOfItemsInSection(), cellForItemAtIndexPath(), and didSelectItemAtIndexPath(). Rather than Row, as the tableView uses, CollectionView uses Item instead. But their responsiblites are basically the same.

Another important thing to note is that you have to defiine a custom cell for each collection view, more than one type if necessary. A new file is needed when defining a custom cell, and don’t forget to add outlets to the corresponding labels or images in storyboard.

UICollectionViewFlowLayout is used to organize the items in a collection view. There are three properties needs to be defined: minimumLineSpacing, minimumInteritemSpacing , and itemSize. Some useful documentation.


Often, view contollers are embedded in Navigation Controller, where all view controllers will have a nav bar at the top. If we want to add items (like buttons) to the nav bar, the one we need is Bar Button Item rather than Navigation Item.

In Navigation Controller, when a view controller is pushed on to the view stack, it will slide from right to left. In the nav bar at the top, there will be a back button, which, when pressed, will automatically pop off the current view controller.


When adding data to table view or collection view dynamically, remember to call tableView.reloadData() or collectionView.reloadData() in the viewWillAppear() function. So when coming back from another view controller after manipulating data, the table view or collection view will also get an update.


In table views, the style of seperator between cells can be set in storyboard. You can have none rather than the ugly grey line.

今天学习内容是在Github Pages上host自己的blog。从Wordpress转移的原因有二:一是其Markdown对代码的支持不好,一是Wordpress本身太过冗杂,有太多我不需要的功能。

Github Pages上有推荐用Jekyll来写博客。经过一些简单的查询,发现Jekyll是一个很好的工具。其功能是将纯文本转换成静态博客网站,正符合我的需要。其中文官网对自己的功能描述如下:

Jekyll 的核心其实是一个文本转换引擎。它的概念其实就是:你用你最喜欢的标记语言来写文章,可以是 Markdown, 也可以是 Textile, 或者就是简单的 HTML, 然后 Jekyll 就会帮你套入一个或一系列的布局中。在整个过程中你可以设置 URL 路径,你的文本在布局中的显示样式等等。这些都可以通过纯文本编辑来实现,最终生成的静态页面就是你的成品了。

明白该工具的用途后便可以进行配置。Github Pages本身支持自动利用Jekyll生成站点,所以并不需要安装过程。但是假如想在本地进行网页开发的话,则需要在本地安装Jekyll。Jekyll Tips上有详细的教程,对我帮助很大。

一个基于Jekyll网站的目录结构通(File Structure)常如下:

.
├── _config.yml
├── _drafts
|   ├── begin-with-the-crazy-ideas.textile
|   └── on-simplicity-in-technology.markdown
├── _includes
|   ├── footer.html
|   └── header.html
├── _layouts
|   ├── default.html
|   └── post.html
├── _posts
|   ├── 2007-10-29-why-every-programmer-should-play-nethack.textile
|   └── 2009-04-26-barcamp-boston-4-roundup.textile
├── _site
├── .jekyll-metadata
└── index.html

(截自官网

官网上对其有详细的解释,这里不再赘述。将Github Pages的repo按上述结构组建好后,Github Pages会自动解析然后生成Jekyll网页。我所需要做的工作则是在_posts/中添加自己的Markdown形式的博客,Jekyll就会帮我生成相对应的html网页。这些网页会被储存在_site/中,但是repo里并不会显示该文件夹。

基本的设置完成后,我开始寻找一些美观的Jekyll Themes,想让自己的博客看起来更赏心悦目一些。最终决定使用的是由Michael Rose制作的HPSTR。该Theme不仅提供美观的前端设置,也包含了许多可以自己customize的内容。

以上工作完成后便将之前在Wordpress上的两篇博客转移过来,用Markdown形式修改保存后放在_posts/,push到repo中。

至此,利用Jekyll在Github Pages上搭建静态博客网站的所有工作全部完成。接下来就需要在README里做一些reference和credit的工作。

今天学习的主要内容之一是UIKit中的UITableView。

UITableView包含两种delegate protocol,分别是UITableViewDelegate和UITableViewDataSource。

第一个的主要作用是对用户的操作做出反馈。例如 didSelectRowAtIndexPath()可以define在用户选择了某个行(indexPath)之后,delegate可做出的反馈。

第二个的主要作用是对数据的提取。例如cellForRowAtIndexPath()会返还给你在该行(indexPath)的cell,然后你可以对该cell做相关的处理,比如添加它textField的内容。再例如,numberOfRowInSection() 可以让你define该tableView总共有多少行——这一般取决于你的data model array的大小。

TableView的内容一般是由一个array来定义的。这个array可以array of struct,也可以是array of dictionaries。

记住,在Storyboard里建立新view controller,拖入table view后,需要将该table view的data source设定为当前view controller


今天另一重点是Navigation Controller。其本质很简单,就是一个stack of view controllers,比如iOS自带的Settings。第一层是一个root view controller;点击一个新选项,这个新的view controllers就被push到stack上,然后被显示出来;点击返回后,这个view controller被pop,它下面的view controller就再次显示出来。

不同view controller之间的transition还是有三种方式:

  • code only - 从Storyboard中通过Identifier实例化新的view controller,然后downcast到这个view controller的type,定义完相关内容后,push到stack上
let resultVC = storyboard?.instantiateViewControllerWithIdentifier("ResultViewController") as! ResultViewController
navigationController?.pushViewController(resultVC, animated: true)
resultVC.property = 10
  • code & segue - 在Storyboard中建立新的segue (show),from VC to VC,定义segue的identifier,然后在view controller 的file里定义prepareForSegue()。当然,还需要一个action来trigger这个segue——performSegueWithIdentifier()。
  • segue only - 通常是从一个button建立segue到一个新的view controller,然后在view controller 的file里定义prepareForSegue()。

Welcome!

Recently I realized the importance of keeping a record of what I learnt every day, especially in this particular period of time in my life – graduated from college. There’s been a lot of thoughts going through my mind lately, so much that I even felt a bit overwhelmed. Thus, I decided to write blogs, to digitize those thoughts – not only to help myself at the moment to keep track of my time and life, but also serve as a reference to the future myself.

My blogs will probably cover a lot of different categories, and they could be written in either English or Chinese. If you are reading this, hope my blogs could be helpful to you in some way. Thank you.

JT

欢迎!

最近我越发意识到记录自己学习与生活的重要性,特别是在现在这个特殊的阶段 ——大学毕业。这一段时间内脑子里总是有各种各样的想法,多到我甚至感到有些压抑。因此,我决定开始写博客,记录下这些想法——不仅为了帮助现在的自己记录生活,也是让未来的自己有个参考。

我的博客会涵盖许多方面的内容,我会用中文或是英文去写下他们。如果你正在读我的博客,希望它能对你有一点点的帮助。谢谢。

Juntian