Translate

2016年5月6日 星期五

nsarray有包含字串

 NSArray *ar=@[@"john",@"bally",@"bill"];
 NSString *check=@"john";
    
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF IN %@", ar];

    BOOL result = [predicate evaluateWithObject:check];

2016年4月14日 星期四

IE11 在win10開啟的錯誤

裝了win10,但要試著開啟ie總是錯誤

試了很多方法,連重設都放了,最後找到解法了

在網際網路>進階>設定找尋為加強的受保護模式啟用64位元處理程序打勾

就可以正常開啟ie了


ref→http://answers.microsoft.com/zh-hant/ie/forum/ie11-iewindows8_1/internet-explorer-11/76b30f71-11db-4198-8a11-f9a1152ea62f?auth=1

2016年4月8日 星期五

webview scales frame

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    webView.scalesPageToFit = YES;
    webView.contentMode = UIViewContentModeScaleAspectFit;
    webView.scrollView.scrollEnabled = NO;
    
    CGSize contentSize = webView.scrollView.contentSize;
    CGSize viewSize = webView.bounds.size;
    
    float rw = viewSize.width / contentSize.width;

    webView.scrollView.minimumZoomScale = rw;
    webView.scrollView.maximumZoomScale = rw;
    webView.scrollView.zoomScale = rw;
    


}

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