Translate

2016年2月23日 星期二

post image


NSData *imageData = UIImageJPEGRepresentation(self.image.image,0);
NSString *url=@"http://test/postimage";

 NSURL *theURL = [NSURL URLWithString:url];
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:8.0f];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setValue:@"application/json" forHTTPHeaderField:@"Accept"];
    [theRequest setValue:@"image/jpg" forHTTPHeaderField:@"Content-Type"];
    theRequest.timeoutInterval=10.0;
    [theRequest setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[imageData length]] forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPBody: imageData];
    
    NSString *result= [self HttpResult:theRequest];
    

字串只留下數字,或只留下文字

using System.Text.RegularExpressions;

string  inputStr = "abc123";

 var outputNum = Regex.Replace( inputStr, @"[\D-]", string.Empty); //只有數字被保留

 var outputStr = Regex.Replace( inputStr, @"[\d-]", string.Empty); //只有文字被保留

2016年2月2日 星期二

UIButton Title



UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

放置 set the button title by state


[rightButton setTitle:cid forState:UIControlStateNormal];

取得 get the button title by state


[rightButton titleForState: UIControlStateNormal]


狀態 state can change you want

 UIControlStateNormal       //正常
 UIControlStateHighlighted  
 UIControlStateDisabled    //無作用狀態
 UIControlStateSelected
 UIControlStateFocused 
 UIControlStateApplication  
 UIControlStateReserved