Time of Update: 2013-12-10
引用 SystemConfiguration.framework#import "SystemConfiguration/SystemConfiguration.h"#include "netdb.h"- (BOOL) connectedToNetwork{ // 建立零地址,0.0.0.0的地址表示查詢原生網路連接狀態 struct sockaddr_in zeroAddress;&
Time of Update: 2013-12-10
1、寫了一個小Demo,實現上下移動的: 主要代碼如下:[cpp]- (IBAction)upChange:(id)sender { if (typeView == down) { [self.downBtn setHidden:NO]; &
Time of Update: 2013-12-10
IOS的view沒有點擊功能,又是和Android 的一大差別,沒辦法,自訂一個,本來是想自己寫一個的,逛了一下github,發現有同行已經寫好了,我也不需要在重複了,這裡只是記錄一下吧: 這裡我們為UIViuew定義了Category,如下:UIView+WhenTappedBlocks.h[cpp] 01.#if NS_BLOCKS_AVAILABLE 02. 03.#import
Time of Update: 2013-12-10
[html] 最近做個項目,有個點擊圖片放大的需求,經過高人指點,學會了在UIView的子類中添加點擊事件方法的技巧,給各位分享一下:首先設定UIView(或其子類)為可互動的:[html] imageview.userInteractionEnabled = YES; 添加tap手勢:[html] //tap手勢
Time of Update: 2013-12-10
今天碰到個奇怪的Bug,且看下面代碼: //選項數組賦值 NSMutableArray *tmpAr = [[NSMutableArray alloc]init]; NSLog(@"%d+++,0 < (tmpAr.count - 100));
Time of Update: 2013-12-10
問題描述:通過使用CLLocationManager得到當前城市和國家的名稱。解決方案:[plain] - (void) getReverseGeocode { CLGeocoder *geocoder = [[CLGeocoder alloc] init]; if(currentLatLong.count > 0) { &
Time of Update: 2013-12-10
1.今天在做一個webservice的介面的時候,被要求傳一個時間戳記過去,然後就是開始在Google上找2.遇到兩個問題,一,目前時間轉化為時間戳記,二,擷取的目前時間和系統的時間相差8個小時一,轉化的方法為 NSString *timeSp = [NSString stringWithFormat:@"%d", (long)[localeDate timeIntervalSince1970]];
Time of Update: 2013-12-10
需要用到NSDateFormatter這個類。1、字串轉換為日期[plain]NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];//執行個體化一個NSDateFormatter對象 [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];//設定時間格式,要注意跟下面的dateString匹配,否則日起將無效 NSDate
Time of Update: 2013-12-10
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; //顯示[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
Time of Update: 2013-12-10
我是建立一個scrollview,然後在裡面添加imageview,imageView的建立主要代碼如下:@interface ImagePageView : UIView@property (nonatomic,retain)UIImageView *imageViewOne;@property (nonatomic,retain)UIImageView *imageViewTwo;- (void)imageViewV:(int)pageNum;-
Time of Update: 2013-12-10
一般同時還有:'retain' is unavailable: not available inautomatic reference counting mode 的錯誤提示 從字面上來解釋就是,arc 禁止顯示發送retain訊息。其實就是使用ARC之後,不允許直接調用retain, release, autorelease, dealloc,
Time of Update: 2013-12-10
1 前言UIBarButtonItem為導覽列按鈕,在導覽列的左側和右側,他們具有許多種不同的形狀和形式。2 代碼講解ZYViewController.m [plain] (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view,
Time of Update: 2013-12-10
typedef enum { UITableViewCellSelectionStyleNone, UITableViewCellSelectionStyleBlue, UITableViewCellSelectionStyleGray} UITableViewCellSelectionStyle//cell右邊按鈕格式typedef enum {
Time of Update: 2013-12-10
IOS 擷取 Document 檔案夾路徑NSFileManager *fileManager = [NSFileManager defaultManager]; NSArray *paths = NSSearchPathForDirectoriesInDomains(
Time of Update: 2013-12-10
從2013-5-1日開始蘋果就禁止對UUID的應用的通過了。所以我們需要用一些辦法替換,下面我就是用keychain的訪問替換掉UUID的。那麼,關於Keychain的應用,Apple提供了一個叫GenericKeychain的例子程式,在這裡:http://developer.apple.com/library/ios/#samplecode/GenericKeychain/Listings/Classes_KeychainItemWrapper_h.html#//apple_ref/doc/
Time of Update: 2013-12-10
複製裡面的 Reachability.h 和 Reachability.m 到項目中2、添加 framework:將 SystemConfiguration.framework 添加進工程。在這裡描述一下樣本中的代碼下面的代碼設定UITextField的值以及顯示的圖片。[cpp]- (void) configureTextField: (UITextField*) textField imageView: (UIImageView*) imageView reachability:
Time of Update: 2013-12-10
KVC(Key Value Coding)KVO(Key Value Observing)KVB(Key Value Binding)KVO是Cocoa的一個重要機制,他提供了觀察某一屬性變化的方法,極大的簡化了代碼。這種觀察-被觀察模型適用於這樣的情況,比方說根據A(數 據類)的某個屬性值變化,B(view類)中的某個屬性做出相應變化。對於推崇MVC的cocoa而言,kvo應用的地方非常廣泛。(這樣的機制聽起來類
Time of Update: 2013-12-10
1 前言通過本次學習,我們就能夠理解在 Objective-C 方法和在 Block Objects 中擷取變數的區別。2 代碼執行個體main.m [plain]#import <Foundation/Foundation.h> #import "TestDemo.h" int main(int argc, const char * argv[]) {
Time of Update: 2013-12-10
1 前言UIPinchGestureRecognizer捕獲並處理類似放大和縮小的手勢動作。2 代碼執行個體ZYViewController.m [plain]- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor
Time of Update: 2013-12-10
1 前言得到圖形環境,然後用 CGContextMoveToPoint 和 CGContextAddLineToPoint 函數來畫線。2 代碼執行個體ZYViewControllerView.m [plain]- (void)drawRect:(CGRect)rect{ [self drawRooftopAtTopPointof:CGPointMake(160.0f, 40.0f) textToDisplay:@"Miter&