顯示具有 iOS Dev 標籤的文章。 顯示所有文章
顯示具有 iOS Dev 標籤的文章。 顯示所有文章

2013年4月26日 星期五

2012年4月2日 星期一

[iOS Dev] 偵測目前網路狀態 WIFI, 3G, Edge - Reachability

一年前寫過一個範例 : [iOS Dev] 簡單的網路連結測試 Simple Internet Connection test

主要是透過NSURL去實際request一個網頁, 然後偵測是否可以連結

今天發現使用Apple有提供一個Sample Code - Reachability, 直接透過C語言的Library來偵測網路狀態

並可以偵測使用者是否使用WIFI, 3G, Edge網路 直接import Reachability.h就可以沿用, 非常方便 

注意: 使用Reachability時, 要記得在專案link SystemConfiguration.framework

詳細請看官方範例::
http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html

2012年3月1日 星期四

[iOS Dev] 開啓殭屍模式 找出EXC_BAD_ACCESS元兇

通常會出現EXC_BAD_ACCESS通常是哪個Object已經被release或是根本不存在

可以開啟Zombie Object來觀看到底是哪個Object不存在

1. ⌥ + ⌘ + R

2. 打勾Enable Zombie Objects


Reference:
http://stackoverflow.com/questions/2190227/how-do-i-setup-nszombieenabled-in-xcode-4

2012年2月24日 星期五

2012年2月23日 星期四

[iOS Dev] 點擊狀態列捲軸往上問題 Tap statusbar scroll to top doesn't work

我有一個UITableView結果發現scroll到下面時

竟然無法點statusbar自動捲到最上面

後來發現是因為我的UITableViewCell裡有UIWebView, 所以action被搶走了

所以只要把UIWebView的scroll to top關掉, 就可以避免這個問題

Code (iOS5):
webView.scrollView.scrollsToTop = NO; 

2012年2月17日 星期五

[iOS Dev] 更改UIKeyboard的底色為黑色

    [inputTextView becomeFirstResponder];
    [inputTextView setKeyboardAppearance:UIKeyboardAppearanceAlert];


原本的Default


更改keyboardAppearance 為 UIKeyboardAppearanceAlert

2012年2月7日 星期二

[iOS Dev] Parse query string into dictionary

Usage:
NSString *qs = @"username=hank&age=27&blog=whhnote.blogspot.com";
NSDictionary *queryParams = [self parseQueryString:qs];
NSLog(@"%@", queryParams);
NSLog(@"%@", [queryParams objectForKey:@"username"]); // get username from dict
So, you will get a dictionary look like
{
    age = 27;
    blog = "whhnote.blogspot.com";
    username = hank;
}

2011年3月25日 星期五

[iOS Dev] Detect App Running on Simulator or Actual Device - 判斷App執行在模擬器或是實體

對於開發時要設定不同參數很有幫助
It's helpful to set different config.

#if TARGET_IPHONE_SIMULATOR
  // It's running on the simulator 目前跑在模擬器上
#else
  // Running on Actual Device  在實機上跑
#endif

2011年3月21日 星期一

[iOS Dev] 日期轉換 Date and Timestamp converter

NSDate *now = [NSDate date];
NSTimeInterval interval = [now timeIntervalSince1970];
NSLog(@"%@", now);   // Date
NSLog(@"%f", interval);    // Date to Timesatmp
NSLog(@"%@", [NSDate dateWithTimeIntervalSince1970:interval]); // Timestamp to Date

2011年3月9日 星期三

[iOS Dev] Filter FetchedResultsController with NSPredicate

NSPredicate *predicate = [NSPredicate predicateWithFormat:
[NSString stringWithFormat:@"(firstName like '%@')", @"Hank"]];

NSArray *items = [fetchedResultsController.fetchedObjects filteredArrayUsingPredicate:predicate];
 
 for (NSManagedObject *o in items) {
  NSLog(@"%@", o);
 }

[iOS Dev] NSDate, NSString conversion and get TimeZone

2011年3月7日 星期一

[iOS Dev] UITableView indentationLevel 縮排


- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath {
 NSUInteger row = [indexPath row];
 return row;
}
Related Posts Plugin for WordPress, Blogger...