PIXNET Logo登入

zer931的部落格

跳到主文

歡迎光臨zer931在痞客邦的小天地

部落格全站分類:不設分類

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 9月 29 週六 201211:38
  • utf8_general_ci 與 utf8_unicode_ci 的不同與差異

utf8_general_ci 與 utf8_unicode_ci 的不同與差異
from http://life.different.idv.tw/scottwu/29.htm
 
(繼續閱讀...)
文章標籤

zer931 發表在 痞客邦 留言(0) 人氣(24)

  • 個人分類:ORACLE
▲top
  • 9月 29 週六 201209:30
  • UITableView cell自訂視圖中插入Table實現複雜介面

image_thumb8.png
UITableView cell自訂視圖中插入Table實現複雜介面
from http://fecbob.pixnet.net/blog/post/35423964
最近專案中需要實現如下圖所示的效果:
  
(繼續閱讀...)
文章標籤

zer931 發表在 痞客邦 留言(0) 人氣(268)

  • 個人分類:技巧篇
▲top
  • 9月 29 週六 201209:28
  • Iphone在table cell中添加自訂佈局view

Iphone在table cell中添加自訂佈局view
from http://fecbob.pixnet.net/blog/post/35424051


在android開發listView中,每一行的清單可以通過相應的xml定義視圖。在iphone開發中,tableView也提供了通過nib自訂視圖的解決方案。這就使開發者能夠完成相當複雜的介面佈局。

 


下麵介紹table中添加自訂的table cell。實現的效果如下:


image_thumb6.png  


實現過程很簡單,首先創建一個table視圖,添加table相應的協定。這一步很簡單,在這裡就不寫如何實現的了。不懂的可以看我以前的博客,或者看原始程式碼。

 


接下來,新建檔 並在 subclass 裡 選擇 UITableViewCell 這裡我命名為 “MyCell”

 


然後在利用IB創建一個名為mycell的nib,在裡面拖入一個UITableViewCell並將其類名改為MyCell。

image_thumb7.png  



-(NSInteger) tableView:(UITableView *)tableView


numberOfRowsInSection:(NSInteger)section


{ 
    return 1; 
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"CustomCellIdentifier"; 
    MyCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
        NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"mycell" owner:self options:nil]; 
        cell = [array objectAtIndex:0]; 
        [cell setSelectionStyle:UITableViewCellSelectionStyleGray]; 
    } 
    [[cell lable] setText:@"你好"]; 
    //[[cell imageView] setImage:[UIImage imageNamed:[imageNameArray objectAtIndex:indexPath.row]]]; 
    //[[cell nameLabel] setText:[nameArray objectAtIndex:indexPath.row]]; 
    return cell; 
} 
- (CGFloat)tableView:(UITableView *)atableView heightForRowAtIndexPath:(NSIndexPath *)indexPath  


{       
    return 90; 
}



專案的原始程式碼:http://easymorse.googlecode.com/svn/trunk/TableCellDemo/


(繼續閱讀...)
文章標籤

zer931 發表在 痞客邦 留言(0) 人氣(94)

  • 個人分類:技巧篇
▲top
  • 9月 26 週三 201216:18
  • 於 CentOS 6.2 安裝 Git, Gitolite 及 Gitlab

於 CentOS 6.2 安裝 Git, Gitolite 及 Gitlab
from http://blog.faq-book.com/?p=5222
由 Calvert 發表於 七月 30, 2012 / 尚無評論
(繼續閱讀...)
文章標籤

zer931 發表在 痞客邦 留言(0) 人氣(107)

  • 個人分類:GIT Linux
▲top
  • 9月 21 週五 201210:06
  • Singletons in Objective-C

Singletons in Objective-C
from http://www.galloway.me.uk/tutorials/singleton-classes/

One of my most used design patterns when developing for iOS is the singleton pattern. It’s an extremely powerful way to share data between different parts of code without having to pass the data around manually. More about the singleton pattern and other patterns can be found in this excellent book:
Background
Singleton classes are an important concept to understand because they exhibit an extremely useful design pattern. This idea is used throughout the iPhone SDK, for example, UIApplication has a method called sharedApplication which when called from anywhere will return the UIApplication instance which relates to the currently running application.
How to implement
You can implement a singleton class in Objective-C using the following code:
MyManager.h
#import <foundation/Foundation.h>
@interface MyManager : NSObject {
NSString *someProperty;
}
@property (nonatomic, retain) NSString *someProperty;
+ (id)sharedManager;
@end
MyManager.m
#import "MyManager.h"
@implementation MyManager
@synthesize someProperty;
#pragma mark Singleton Methods
+ (id)sharedManager {
static MyManager *sharedMyManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedMyManager = [[self alloc] init];
});
return sharedMyManager;
}
- (id)init {
if (self = [super init]) {
someProperty = [[NSString alloc] initWithString:@"Default Property Value"];
}
return self;
}
- (void)dealloc {
// Should never be called, but just here for clarity really.
}
@end
What this does is it defines a static variable (but only global to this translation unit)) called sharedMyManager which is then initialised once and only once in sharedManager. The way we ensure that it’s only created once is by using the dispatch_once method from Grand Central Dispatch (GCD). This is thread safe and handled entirely by the OS for you so that you don’t have to worry about it at all.
However, if you would rather not use GCD then you should use the following code for sharedManager:
Non-GCD based code
+ (id)sharedManager {
@synchronized(self) {
if (sharedMyManager == nil)
sharedMyManager = [[self alloc] init];
}
return sharedMyManager;
}
Then you can reference the singleton from anywhere by calling the following function:
MyManager *sharedManager = [MyManager sharedManager];
I’ve used this extensively throughout my code for things such as creating a singleton to handle CoreLocation or CoreData functions.
Non-ARC code
Not that I recommend it, but if you are not using Automatic Reference Counting (ARC), then you should use the following code:
MyManager.h non-ARC
#import "MyManager.h"
static MyManager *sharedMyManager = nil;
@implementation MyManager
@synthesize someProperty;
#pragma mark Singleton Methods
+ (id)sharedManager {
@synchronized(self) {
if(sharedMyManager == nil)
sharedMyManager = [[super allocWithZone:NULL] init];
}
return sharedMyManager;
}
+ (id)allocWithZone:(NSZone *)zone {
return [[self sharedManager] retain];
}
- (id)copyWithZone:(NSZone *)zone {
return self;
}
- (id)retain {
return self;
}
- (unsigned)retainCount {
return UINT_MAX; //denotes an object that cannot be released
}
- (oneway void)release {
// never release
}
- (id)autorelease {
return self;
}
- (id)init {
if (self = [super init]) {
someProperty = [[NSString alloc] initWithString:@"Default Property Value"];
}
return self;
}
- (void)dealloc {
// Should never be called, but just here for clarity really.
[someProperty release];
[super dealloc];
}
@end
(繼續閱讀...)
文章標籤

zer931 發表在 痞客邦 留言(0) 人氣(75)

  • 個人分類:基本概念
▲top
  • 9月 15 週六 201214:11
  • Standard Touch Delegate and Targeted Touch Delegate

Cocos2d 2.0 Touch Input
from http://zackworkshopios.blogspot.tw/2012/06/cocos2d-touch-input.html
 
(繼續閱讀...)
文章標籤

zer931 發表在 痞客邦 留言(0) 人氣(20)

  • 個人分類:基本概念
▲top
  • 9月 13 週四 201210:25
  • 初探ARC - Automatic Reference Counting


初探ARC - Automatic Reference Counting
from http://popcornylu.blogspot.tw/2011/06/arc-automatic-reference-counting.html
 
(繼續閱讀...)
文章標籤

zer931 發表在 痞客邦 留言(0) 人氣(56)

  • 個人分類:基本概念
▲top
  • 9月 02 週日 201211:07
  • NSMutableArray Sort

NSMutableArray Sort
 from http://sorrowslee.blogspot.tw/2012/07/nsmutablearray-nsstring-sortorder-array.html

今天來分享一下NSMutableArray的排序方式
NSString *sortOrder = @"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz_0123456789";

[array sortUsingComparator:^NSComparisonResult(id obj1, id obj2)
{
char char1 = [(NSString *)obj1 characterAtIndex: 0];
char char2 = [(NSString *)obj2 characterAtIndex: 0];

int index1;
for (index1 = 0; index1 < sortOrder.length; index1++)
if ([sortOrder characterAtIndex: index1] == char1)
break;

int index2;
for (index2 = 0; index2 < sortOrder.length; index2++)
if ([sortOrder characterAtIndex: index2] == char2)
break;

if (index1 < index2)
return NSOrderedAscending;
else if (index1 > index2)
return NSOrderedDescending;
else
return [(NSString *)obj1 compare: obj2 options: NSCaseInsensitiveSearch];
}];


這樣Array就會照英文跟數字的方式來排序了
(繼續閱讀...)
文章標籤

zer931 發表在 痞客邦 留言(0) 人氣(37)

  • 個人分類:技巧篇
▲top
  • 9月 02 週日 201209:44
  • 製作基本的 Animate Sprites


製作基本的 Animate Sprites
from http://furnacedigital.blogspot.tw/2011/09/animate-sprites.html
 
(繼續閱讀...)
文章標籤

zer931 發表在 痞客邦 留言(0) 人氣(186)

  • 個人分類:基本概念
▲top
  • 8月 31 週五 201214:21
  • 我用cocos2D做出滑動選單了


我用cocos2D做出滑動選單了
from http://bearuwork.blogspot.tw/2011/08/cocos2d_10.html
 
(繼續閱讀...)
文章標籤

zer931 發表在 痞客邦 留言(0) 人氣(131)

  • 個人分類:基本概念
▲top
«1...45610»

個人資訊

zer931
暱稱:
zer931
分類:
不設分類
好友:
累積中
地區:

熱門文章

  • (4,556)[Oracle] Cursor 與 Cursor Variable 的使用
  • (263)取得指南針 / 羅盤 / Magnetometer 數值的方法
  • (3,979)VMware 的 Bridged, Host-only 和 NAT 網路型態
  • (4,493) NO-IP 使用教學
  • (247)搭建 Windows 上 Apache + Git 服务器
  • (141)NSArray與NSMutableArray與NSMutableDictionary
  • (7,042)C/C++ 箭頭(->) 、點(.)、雙冒號(::) 用法
  • (314)iOS 開發筆記 - 國曆轉農曆計算

文章分類

toggle GIT (3)
  • GIT MAC (1)
  • GIT Linux (2)
  • GIT Win (9)
toggle PHP (3)
  • Server 設定 (4)
  • 程式技巧篇 (4)
  • PDO (1)
toggle COCOS2D (2)
  • BOX2D (2)
  • 基本概念 (21)
toggle IOS (4)
  • PUSH SERVER (2)
  • 基本概念 (21)
  • DataBase (3)
  • 技巧篇 (20)
  • VMWare (3)
  • Winodws (2)
  • C++ (2)
  • ORACLE (2)
  • 未分類文章 (1)

最新文章

  • PHP.INI 打開DeBug模式
  • [JavaScript]null & undefined
  • 使用PDO時 產生 Zend Debugger Socket link error
  • phpMyAdmin sql query that uses parameters
  • PDO 介紹範例網址
  • genstrings across 多元路徑 Localizable
  • 實作 TableView Section 展開/收合
  • 分享一个搭建php版push服务器的流程
  • Push pem文件生成步骤
  • mac eclipse 設定php debugger

動態訂閱

文章精選

文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: