[iOS] 程式片段 : Code Snippets

文字框輸入完 keyboard 收起來

// --- define :
@property (nonatomic, retain) IBOutlet UITextField *txtInput;

// --- code :

- (BOOL)textFieldShouldReturn:(UITextField *)theTextFied {

	if(txtInput == theTextFied)
	{
		[txtInput resignFirstResponder];
	}

	//Update the label.
	lblMessage.text = txtInput.text;

	return YES;
}

ex: http://furnacedigital.blogspot.tw/2012/01/blog-post_20.html#more

 

 

 

 

陣列 Array 用法

    NSArray *array =[ [NSArray alloc] initWithObjects:
		@"銷售總覽",
		@"訂單管理",
		@"上架商品",
		@"廣告中心",
		nil
	];
    self.listdata = array;
    [array release];

 

NSArray :

NSArray *myArray;
NSDate *aDate = [NSDate distantFuture];
NSValue *aValue = [NSNumber numberWithInt:5];
NSString *aString = @"a string";

myArray = [NSArray arrayWithObjects:aDate, aValue, aString, nil];