iPhone 编程常用代码
1、WebView显示Html。
[WebView setOpaque:NO];
[WebView setBackgroundColor:[UIColor clearColor]];
NSString* gifFileName = @"j_0002.gif";
NSMutableString* htmlStr = [NSMutableString string];
[htmlStr appendString:@"Hello Honey"];
[htmlStr appendString:@"<p><img src=\""];
[htmlStr appendFormat:@"%@",gifFileName];
[htmlStr appendString:@"\" alt=\"picture\"/>"];
[WebView loadHTMLString:htmlStr baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
[WebView setBackgroundColor:[UIColor clearColor]];
NSString* gifFileName = @"j_0002.gif";
NSMutableString* htmlStr = [NSMutableString string];
[htmlStr appendString:@"Hello Honey"];
[htmlStr appendString:@"<p><img src=\""];
[htmlStr appendFormat:@"%@",gifFileName];
[htmlStr appendString:@"\" alt=\"picture\"/>"];
[WebView loadHTMLString:htmlStr baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
2、Convert date string to date object
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
NSDate *formatterDate = [inputFormatter dateFromString:@"2010-01-08T08:09:20Z"];
[inputFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
NSDate *formatterDate = [inputFormatter dateFromString:@"2010-01-08T08:09:20Z"];