在這- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
加入
if (indexPath.section == 1 && indexPath.row == 1) {
cell.textLabel.text = @"I Have A Switch";
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero];
cell.accessoryView = switchView;
[switchView setOn:NO animated:NO];
[switchView addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
[switchView release];
}
2013年3月7日 星期四
2013年3月6日 星期三
How to interact with UITableView in UIViewController?
Implement UITableViewDataSource and UITableViewDelegate protocols in your view controller .h file.
@interface ThirdViewController : UIViewController
Have an outlet for the UITableView.
@property (retain, nonatomic) IBOutlet UITableView *SMSTableView;
In viewDidLoad, set the tableView's datasource and delegate to self since the viewcontroller implements the protocol.
tableView.delegate = self;
tableView.dataSource = self;
Then, write the cellForRowAtIndexPath method.
It will be getting called.
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { #warning Potentially incomplete method implementation.
// Return the number of sections.
return 3; }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 10; }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
return cell; }
@interface ThirdViewController : UIViewController
Have an outlet for the UITableView.
@property (retain, nonatomic) IBOutlet UITableView *SMSTableView;
In viewDidLoad, set the tableView's datasource and delegate to self since the viewcontroller implements the protocol.
tableView.delegate = self;
tableView.dataSource = self;
Then, write the cellForRowAtIndexPath method.
It will be getting called.
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { #warning Potentially incomplete method implementation.
// Return the number of sections.
return 3; }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 10; }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
return cell; }
2013年3月5日 星期二
在viewController中使用delegate中宣告的變數的方法
在需要的類別內記得#import 'AppDelegate.h'
並在此類別.m加入
AppDelegate* delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
使用上的話,就可以用 delegate.tmp_int 做存取
並在此類別.m加入
AppDelegate* delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
使用上的話,就可以用 delegate.tmp_int 做存取
加入登入畫面的方法
In your AppDelegate, at the end of the application didFinishLaunchingWithOptions method you'll see this:
[window addSubview:tabcontroller.view];
[window makeKeyAndVisible];
return YES;
Simply initialize your login view controller and add it after the tabcontroller, like this: initialScreenViewController = [[InitialScreenViewController alloc] init];
self.window.rootViewController = self.tabBarController;
//[self.window addSubview:self.tabBarController.view];
//[self.window addSubview:viewController1.view];
[self.window makeKeyAndVisible];
[self.tabBarController presentViewController:viewController1 animated:NO completion:^{ ; }];
return YES;
In you login viewcontroller, after authenticating the user you can hide it like this:
AppDelegate* delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[delegate.tabBarController dismissViewControllerAnimated:YES completion:^{ ; }];
which allows you to show it again if you have a logout feature.
[window addSubview:tabcontroller.view];
[window makeKeyAndVisible];
return YES;
Simply initialize your login view controller and add it after the tabcontroller, like this: initialScreenViewController = [[InitialScreenViewController alloc] init];
self.window.rootViewController = self.tabBarController;
//[self.window addSubview:self.tabBarController.view];
//[self.window addSubview:viewController1.view];
[self.window makeKeyAndVisible];
[self.tabBarController presentViewController:viewController1 animated:NO completion:^{ ; }];
return YES;
In you login viewcontroller, after authenticating the user you can hide it like this:
AppDelegate* delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[delegate.tabBarController dismissViewControllerAnimated:YES completion:^{ ; }];
which allows you to show it again if you have a logout feature.
內嵌Kal Calender
一,下載Kal存在固定路徑ex: /Users/HouKang/Desktop/Kal/src
二,將src中的Kal.xcodeproj拖進xcode中自已的專案裡
三,若跳出複製的對話框,不要勾選 Copy items into destination group's folder
選擇Create folder references for any added folders按下add
四,在專案的Target中的Build Setting
1、把Search Paths的Header Search Paths加入剛剛存好的固定路徑ex: /Users/HouKang/Desktop/Kal/src
2、把Linking的Other Lingker Flags加上"-all_load"
五,在專案的Target中的Summary下的Linked Frameworks and Libraries加入libKal.a
六,在專案的Target中的Build Phases下的Target Dependencies加入Kal
七,把Kal.bundle拖出來到自已的專案中,
若跳出複製的對話框,不要勾選 Copy items into destination group's folder
選擇Create folder references for any added folders按下add
八,在VIEW DID LOAD中填入下列二行即可插入
KalViewController *calendar = [[KalViewController alloc] init]; [self.navigationController pushViewController:calendar animated:YES];
修改KAL畫面
一,在Classes下的KalGridView.m中的const CGSize kTileSize = { 46.f, 24.f };
可以設定基本儲存格大小。
二,在Classes下的KalTileView.m中的CGFloat fontSize = 24.f;
可以調整行事曆數字字體大小
使用SAMPLE
一,用之前要去Kal Project中的TARGETS中的Build Phases下的Link Binary With Libraries把libKal.a給移除
調整event marker的位置
一,在Class下的KalTileView.m中的
if (flags.marked) [markerImage drawInRect:CGRectMake(21.f, 5.f, 4.f, 5.f)];
可以調整marker在Tile中的位置
二,將src中的Kal.xcodeproj拖進xcode中自已的專案裡
三,若跳出複製的對話框,不要勾選 Copy items into destination group's folder
選擇Create folder references for any added folders按下add
四,在專案的Target中的Build Setting
1、把Search Paths的Header Search Paths加入剛剛存好的固定路徑ex: /Users/HouKang/Desktop/Kal/src
2、把Linking的Other Lingker Flags加上"-all_load"
五,在專案的Target中的Summary下的Linked Frameworks and Libraries加入libKal.a
六,在專案的Target中的Build Phases下的Target Dependencies加入Kal
七,把Kal.bundle拖出來到自已的專案中,
若跳出複製的對話框,不要勾選 Copy items into destination group's folder
選擇Create folder references for any added folders按下add
八,在VIEW DID LOAD中填入下列二行即可插入
KalViewController *calendar = [[KalViewController alloc] init]; [self.navigationController pushViewController:calendar animated:YES];
修改KAL畫面
一,在Classes下的KalGridView.m中的const CGSize kTileSize = { 46.f, 24.f };
可以設定基本儲存格大小。
二,在Classes下的KalTileView.m中的CGFloat fontSize = 24.f;
可以調整行事曆數字字體大小
使用SAMPLE
一,用之前要去Kal Project中的TARGETS中的Build Phases下的Link Binary With Libraries把libKal.a給移除
調整event marker的位置
一,在Class下的KalTileView.m中的
if (flags.marked) [markerImage drawInRect:CGRectMake(21.f, 5.f, 4.f, 5.f)];
可以調整marker在Tile中的位置
2013年3月4日 星期一
頁面折疊
做的很有 clear 的感覺:http://www.realmacsoftware.com/clear/
Paul Wu 也貼了兩個類clear的 iOS project :
https://github.com/mpospese/MPFoldTransition
https://github.com/mystcolor/jtgesturebasedtableviewdemo
Paul Wu 也貼了兩個類clear的 iOS project :
https://github.com/mpospese/MPFoldTransition
https://github.com/mystcolor/jtgesturebasedtableviewdemo
好用的外插元件
KissXml——xml解析庫
相關教程:http://www.iteye.com/topic/625849
http://sencho.blog.163.com/blog/static/83056228201151743110540/
很方便的一個xml解析器,支持Xpath查詢。
skpsmtpmessage——Quick SMTP郵件發送
svn checkout http://skpsmtpmessage.googlecode.com/svn/trunk/ skpsmtpmessage-read-only
github: git clone https://github.com/kailoa/iphone-smtp.git
相關教程:http://disanji.net/2011/01/28/skpsmtpmessage-open-source-framework/
skpsmtpmessage 是由Skorpiostech, Inc.为我們帶來的一個SMTP協議的開源實現,使用Objective-c 實現,iOS系統的項目可以直接調用。
jsonframework——JSON支持
相關教程:http://blog.csdn.net/xiaoguan2008/article/details/6732683
它是一個開源框架,基於BSD協議發布。由於json-framework是開放源代碼的,當你需要使用它時你只需將json的源代碼加入到你的工程中。
ASIHttpRequest——HTTP Network庫
ASIHttpRequest庫極大的簡化了網络通 信,提供更先進的工具,例如文件上傳工具,重定向處理工具、驗證工具、等等。
MBProgressHUD——進展指示符庫
蘋果的應用程序一般都會用一種優雅的,半透明的進度顯示效果,不過這個API是不公開的,因此你要是用了,很可能被清除出AppStore。而 MBProgressHUD提供了一個替代方案,而且在用戶角度上,實現的效果根本看不出和官方程序有什麼差別。同時還提供了其他附加功能,比如虛擬進展 指示符,以及完成提示信息。整合到項目裏也很容易,這裏不細談了。
zxing——二維碼掃描庫
支持條形碼/二維碼掃描的圖形處理庫,這是一個java庫,在android上的功能比較完整。同時該庫也支持ios,但只能支持二位條形碼的掃描。
kal——iPhone日曆控件
一個類似於ios系統默認日曆開源日曆庫,支持添加事件,自定義日曆样式等功能。
Facebook iOS SDK——Facebook API類庫
大體來講就是iPhone上的Facebook login,完全支持Facebook Graph API和the older REST api。
shareKit——分享庫
相關demo:http://www.cocoachina.com/bbs/read.php?tid-71760.html
分享到開心,豆瓣,騰訊,新浪微博的api所用到的強大的分享庫。
SDWebImage——簡化網络圖片處理
用SDWebImage調用網站上的圖片,跟本地調用內置在應用包裏的圖片一样簡單。操作也很簡單。
GData client——iPhone上所有Google相關服務的類庫
名字就說明一切了。跟Google相關的,值得一提的是,這個項目很開放。有很多示例程序供下載。
CorePlot——2D圖形繪圖儀
CorePlot有很多解决方案將你的數據可視。同時也會提供各種迷人的圖形效果,比如棒狀圖、餅狀圖、線狀圖等等,在他們網站上也提供了大量的範例圖形,很多股票價格應用,遊戲分數,個人财務管理都在用。
Three20——類似於Facebook的優秀的UI庫
Three20類庫是Facebook自己做的,大而全是他最大的特色。把他整合到已有的項目中可能得費點周折,不過如果一開始你就用上了Three20,尤其是牽扯到很多web相關的項目的時候,你就能深刻體會到神馬叫给力了。
FMDatabase——SQLite的Objective-C封裝
是SQLite的C API對初學者來說實在太麻煩太瑣碎,難度太高。FMDB說穿了其實只是把C API包裝成簡單易用的Objective-C類。對於SQLite初學者來說,大大減低了上手的難度。有了FMDB,寫程式時只要專心在SQLite的語法上,而不用去理那堆有看沒有懂的C API,實在是件快樂的事情。
訂閱:
文章 (Atom)