星期五, 5月 30, 2014

[iOS] 使用Navigation Controller 切換ViewController

今天練習透過用Storyboard viewcontroller將畫面跳轉至xib viewcontroller。

主畫面storyboard的MultiViewViewController.h
//呼叫xib視窗
-(IBAction)twoXibClicked:(id)sender{

    //產生一個xib的ctrl instance
    
    TwoViewController *twoViewCtrl = [[TwoViewController alloc]
                                                  initWithNibName:@"TwoViewController"
                                                  bundle:nil];

    //透過navigationcontroller推到xib的controller
    [self.navigationController pushViewController:twoViewCtrl animated:YES];
    
    
//    [twoViewCtrl release];
}

使用xib的TwoViewController.m
- (IBAction)xibBackToMainClicked:(id)sender {
    
    //使用navigation退回主畫面
    [self.navigationController popToRootViewControllerAnimated:YES];
}

找到這篇討論Navigation多次跳轉的問題: navigationController pushViewController 多次跳转后怎么返回


返回根页面vc用:
[self.navigationController popToRootViewController]
返回指定的某个vc用下面(通过index定位)
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];
或(通过class定位):
for (UIViewController *controller in self.navigationController.viewControllers) {

    if ([controller isKindOfClass:[你要跳转到的Controller class]]) {

        [self.navigationController popToViewController:controller animated:YES];

    }

}

星期四, 5月 29, 2014

[iOS] 導覽列與Storyboard

經過第一個範例([iOS] 快快樂樂寫iOS hello world (storyboards))練習後,
接著要開始多個頁面的切換練習,這次要練習透過storyboard切換不同的ViewContoller。

版本

XCode 5 


開始實作


Step1: 新增第二個ViewController

在第一個ViewController放入一個按鈕(取Load from storyboard),
然後在Object Library拖進來第二個ViewController

星期三, 5月 28, 2014

[iOS] 快快樂樂寫iOS hello world (storyboards)

萬事起頭難XD克服第一個helloworld iOS程式。
這個範例是參考 http://ios-blog.co.uk/tutorials/ios-7-hello-world-tutorial/
不過有改了一些操作方法:D
另一篇則有簡單的Xcode IDE的介紹:http://codewithchris.com/hello-world-iphone-app/

版本

XCode 5 

題目

透過二個按鈕來操作count次數,並將count的結果顯示在label上


星期二, 5月 27, 2014

[jQuery Plugins] 替Fancybox加上客制化按鈕

最近想要替fancybox的圖片加上額外控制,找到了以下這篇範例:

這是直接修改原始碼的範例
http://nsdiv.blogspot.tw/2010/05/adding-custom-buttons-to-jquerys.html

由於是後台介面的需求,感覺加個contextmenu還比較快速,
畢竟contextmenu的外掛實在太多了,
以下是用bootstrap打造的contextmenu範例,
先把它收錄到Gist: https://gist.github.com/iambigd/b892a10343be7e25033d


[jQuery Plugins] 十一個屌b的jquery網站導覽外掛

這篇文章介紹了十一種很屌的jQuery屌b的網站導覽外掛,
對一個新網站非常適合導入這種教學:D 

11 Awesome “jQuery Site Tour Plugins” For Guiding Users With Style

星期一, 5月 26, 2014

[Java] 快快樂樂學會log4j

最近弄log4j的同事離職,趁記憶還在的時候,
自已親身再run一遍,本文大多取自Google來的各文章的筆記。

log4j使用版本:1.2.x

[Blogger HACK] 使用Google drive來儲存(HOST) CSS/Javascript 資源

我們常常會把一些第三方的資源(ex: jquery/bootstrap)整合到Blogger中,
但因為部份的提供資源的作者,並沒有提供CDN的網址來取存這個資源,
如果將這些程式碼都加到樣版上,肯定不好管理與維護。
如果有你這些困擾,你現在可以將這些資源(檔案)上傳至Google Drive上。

星期三, 5月 21, 2014

[Javascript] 常用到的日期字串轉日期物件方法

常常遇到日期字串要轉來轉去,以下是轉換的方法。
提醒自已別再忘記了XD


/*Date control*/

function convStrToDate(dateStr){
 var parseDateObj = parseDate(dateStr); //.replace(/-/g,"/");
 // $.console("parse:" + parseDateObj);
 var convDate = new Date(Date.parse(parseDateObj));
 return convDate;
}

function convDateToStr(dateObj) {
 var year = dateObj.getFullYear();
 var month = dateObj.getMonth() + 1;
 var date = dateObj.getDate();
 var hour = dateObj.getHours();
 var minute = dateObj.getMinutes();
 var second = dateObj.getSeconds();

 return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
}

function parseDate(dateStr) {
 var a = $.map(dateStr.split(/[^0-9]/), function(s) {
  return parseInt(s, 10)
 });
 return new Date(a[0], a[1] - 1 || 0, a[2] || 1, a[3] || 0, a[4] || 0, a[5] || 0, a[6] || 0);
}

星期五, 5月 16, 2014

[CI] 使用CI框架打造REST Server

現在已經是REST API的時代XD,幾乎每個語言都有支援快速打造REST框架的方法。
剛好最近在用CI,果然Github就有資源啦

https://github.com/philsturgeon/codeigniter-restserver

作者還有詳細的說明,請參照他的部落格

Working with RESTful Services in CodeIgniter

看不慣英文也有對岸的工程屍翻譯XD

使用CodeIgniter 创建 RESTful 服务 REST API【原创译文】


星期四, 5月 15, 2014

[jQuery Plugin] 視差滾動套件

https://github.com/stephband/jparallax
https://github.com/IanLunn/jQuery-Parallax
http://ianlunn.co.uk/articles/recreate-nikebetterworld-parallax/
http://www.minwt.com/webdesign-dev/js/9082.html

[HTML X CSS X Javascript] 透過影片的教學方式教你學HTML5 CSS3 Javascript..

從fb轉貼來的好站,供大家參考。

http://thecodeplayer.com/

Learn HTML5, CSS3, Javascript and more... Video style walkthroughs showing cool stuff being created from scratch

星期日, 5月 11, 2014

[jQuery] 常見的javascript樣版外掛

這篇記錄一下目前搜尋到的一些常用的javascript樣版引擎。 至於要選擇哪一種工具好像是見人見智,目前只有Linkedin所使用的dust.js有一些評估數據可以參考。

另外也有一個網址Template-Engine-Chooser列出了幾個選擇樣版的常見問題,透過這些問題他會給你一些你可參考的樣版語言有哪些xd


樣版的參考

jquery template


The original official jQuery Templates plugin. This project was maintained by the jQuery team as an official jQuery plugin. It is no longer in active development, and will be superseded by JsRender.

JS Render


A lightweight but powerful templating engine, highly extensible, without DOM or jQuery dependency.

handlebars.js


Handlebars provides the power necessary to let you build semantic templates effectively with no frustration. Mustache templates are compatible with Handlebars, so you can take a Mustache template, import it into Handlebars, and start taking advantage of the extra Handlebars features.

hogan.js

A compiler for the Mustache templating language

Mustache.js

Minimal templating with {{mustaches}} in JavaScript

Pure.js

Simple and ultra-fast templating tool to generate HTML from JSON data Keep your HTML clean of any logic Using JSON and Javascript only Works standalone or with dojo, DomAssistant, Ext JS, jQuery, Mootools, Prototype, Sizzle and Sly


Dust.js

linkedin使用的樣版,還有說明為何要使用此樣版。


  1. Leaving JSPs in the dust: moving LinkedIn to dust.js client-side templates
  2. The client-side templating throwdown: mustache, handlebars, dust.js, and more


Google Closure Templates

Closure Templates are a client- and server-side templating system that helps you dynamically build reusable HTML and UI elements. They have a simple syntax that is natural for programmers, and you can customize them to fit your application's needs. In contrast to traditional templating systems, in which you must create one monolithic template per page, you can think of Closure Templates as small components that you compose to form your user interface. You can also use the built-in message support to easily localize your applications. Closure Templates are implemented for both JavaScript and Java, so that you can use the same templates on both the server and client side. They use a data model and expression syntax that work for either language. For the client side, Closure Templates are precompiled into efficient JavaScript.


星期一, 5月 05, 2014

[Eclipse] 讓Eclipse支援Subline Text Minimap功能 part (2) - Overview plugin

繼上一篇Github找到的mini map在自已的環境執行後有bug XD,
所以再找了另外一套 Overview Plugin ,功能上更強一點,安裝方法更簡單 :D

安裝方法:

Help-> Eclipse marketplace

[Eclipse] 保護眼精好幫手 Eclipse color theme

想要快速設定你的Eclipse開發source code,降低眼精的疲勞嗎?
你不需要一個一個設定,只需要安裝Eclipse color theme   XD

安裝方法:

步驟一:透過Eclipse marketplace就可以快速安裝了


[Eclipse] 讓Eclipse支援Subline Text Minimap功能 part (1) - Mini map plugin

由於下班都用Sublime Text開發,
本來就提供mini map的元件,
要找到要移動的程式碼位置非常省時(配合超大的註解區塊)
上班的公司因為採用Java解決方案,所以採用Eclipse IDE開發,
為了省時還是來裝一下Mini map,雖然拖了很久XD

Github minimap view plugin:

https://github.com/apauzies/eclipse-minimap-view

安裝方法:

下載後把dropins資料複製到你的Eclipse/dropins就好了 :D,接著重啟你的Eclipse

星期六, 5月 03, 2014

星期四, 5月 01, 2014

[AngularJS] 常見問題 $watch 、$apply 筆記

這篇記錄一下查了一些有關$watch$apply的相關資料,
這二個東西又會牽扯到Angular data-binding的相關知識,
建議可以看這篇stackoverflow Using scope.$watch and scope.$apply 

[Sublime Text 2] 用Space轉為Tab

常常會用到Tab鍵來排版,先前tab都會使用空白字元排版,如果想要換掉的話,可以參考以下方法。

首頁你可以變更你的使用者偏好設定檔: 


"tab_size": 4,
"translate_tabs_to_spaces": false,

以下二種設定的方法:

其他你感興趣的文章

Related Posts with Thumbnails