1、存储写入文件
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:文件名];
2、读取资源文件地址
NSString *picPath = [[NSBundle mainBundle] pathForResource:@"文件名" ofType:@"类型"];
3、RGB值配色
NSRange range;
range.length = 2;
range.location = 1;
[[NSScanner scannerWithString:[str substringWithRange:range]] scanHexInt:&red];
range.location = 3;
[[NSScanner scannerWithString:[str substringWithRange:range]] scanHexInt:&green];
range.location = 5;
[[NSScanner scannerWithString:[str substringWithRange:range]] scanHexInt:&blue];
UIColor *color = [UIColor colorWithRed:red/255.0f green:green/255.0f blue:blue/255.0f alpha:1];
4、UINavigationBar属性设置
[nav setBackgroundImage:[[Resources sharedResources] getAppLogo]forBarMetrics:UIBarMetricsDefault];
UIBarButtonItem *closeButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"关闭" style:UIBarButtonItemStylePlain target:self action:@selector(closeWebView)];
UINavigationItem *navgationItem = [[UINavigationItem alloc] initWithTitle:nil];
[nav pushNavigationItem:navgationItem animated:NO];
[navgationItem setRightBarButtonItem:closeButtonItem];
[view addSubview:nav];
[closeButtonItem release];
[nav release];
[navigationItem setTitle:@"TITLE"];
5、获取SIM卡运营商
- (NSString *)theTelephoneNetworkInfo
{
NSString *thePhoneNetworkInfo = nil;
CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [info subscriberCellularProvider];
[info release];
thePhoneNetworkInfo = carrier.carrierName;
return thePhoneNetworkInfo;
}
6、判断设备版本
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000 (50000 表示 5.0)
#endif
size = [label.text sizeWithFont:label.font constrainedToSize:CGSizeMake(300, 2000.0f) lineBreakMode:UILineBreakModeCharacterWrap];
label.numberOfLines = 0;
label.size = size;
label.lineBreakMode = UILineBreakModeCharacterWrap;
1、前6位数(TAC,TYPE APPROVAL CODE)是“型号核准号码”,一般代表机型。
2、接着的两位数字(FAC,Final Assembly Code)是“最后装配号”,一般代表产地。
3、之后的6位数(SNR)是“串号”,一班代表生产顺序号。
4、最后一位数(SP)通常是“0”,为校验码,目前暂备用。
9、判断网络连接
程序中首先需要添加Reachability.h 和 Reachability.m文件,导入SystemConfiguration.framework
- (void)isHaveInternet{
Reachability *r = [Reachability reachabilityWithHostName:@"www.apple.com"];
switch ([r currentReachabilityStatus])
{
case NotReachable: // 没有网络连接
NSLog(@"没有网络");
break;
case ReachableViaWWAN: // 使用3G网络
NSLog(@"正在使用3G网络");
break;
case ReachableViaWiFi: // 使用WiFi网络
NSLog(@"正在使用wifi网络");
break;
}
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:文件名];
2、读取资源文件地址
NSString *picPath = [[NSBundle mainBundle] pathForResource:@"文件名" ofType:@"类型"];
3、RGB值配色
NSString *str = @"#63729F";
unsigned green,red,blue;
NSRange range;
range.length = 2;
range.location = 1;
[[NSScanner scannerWithString:[str substringWithRange:range]] scanHexInt:&red];
range.location = 3;
[[NSScanner scannerWithString:[str substringWithRange:range]] scanHexInt:&green];
range.location = 5;
[[NSScanner scannerWithString:[str substringWithRange:range]] scanHexInt:&blue];
UIColor *color = [UIColor colorWithRed:red/255.0f green:green/255.0f blue:blue/255.0f alpha:1];
4、UINavigationBar属性设置
[nav setBackgroundImage:[[Resources sharedResources] getAppLogo]forBarMetrics:UIBarMetricsDefault];
UIBarButtonItem *closeButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"关闭" style:UIBarButtonItemStylePlain target:self action:@selector(closeWebView)];
UINavigationItem *navgationItem = [[UINavigationItem alloc] initWithTitle:nil];
[nav pushNavigationItem:navgationItem animated:NO];
[navgationItem setRightBarButtonItem:closeButtonItem];
[view addSubview:nav];
[closeButtonItem release];
[nav release];
[navigationItem setTitle:@"TITLE"];
5、获取SIM卡运营商
- (NSString *)theTelephoneNetworkInfo
{
NSString *thePhoneNetworkInfo = nil;
CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [info subscriberCellularProvider];
[info release];
thePhoneNetworkInfo = carrier.carrierName;
return thePhoneNetworkInfo;
}
6、判断设备版本
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000 (50000 表示 5.0)
#endif
7、label根据字符串长度自动换行并增加label的高度
size = [label.text sizeWithFont:label.font constrainedToSize:CGSizeMake(300, 2000.0f) lineBreakMode:UILineBreakModeCharacterWrap];
label.numberOfLines = 0;
label.size = size;
label.lineBreakMode = UILineBreakModeCharacterWrap;
300----->label的宽度
//字符串去空格
NSString *temp = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
//看剩下的字符串的长度是否为零
if ([temp length]!=0) {
return;
}
8、IMEI
1、前6位数(TAC,TYPE APPROVAL CODE)是“型号核准号码”,一般代表机型。
2、接着的两位数字(FAC,Final Assembly Code)是“最后装配号”,一般代表产地。
3、之后的6位数(SNR)是“串号”,一班代表生产顺序号。
4、最后一位数(SP)通常是“0”,为校验码,目前暂备用。
9、判断网络连接
程序中首先需要添加Reachability.h 和 Reachability.m文件,导入SystemConfiguration.framework
- (void)isHaveInternet{
Reachability *r = [Reachability reachabilityWithHostName:@"www.apple.com"];
switch ([r currentReachabilityStatus])
{
case NotReachable: // 没有网络连接
NSLog(@"没有网络");
break;
case ReachableViaWWAN: // 使用3G网络
NSLog(@"正在使用3G网络");
break;
case ReachableViaWiFi: // 使用WiFi网络
NSLog(@"正在使用wifi网络");
break;
}
}