//查找字体名
NSArray *array = [UIFont familyNames]; for (NSString * familyname in array) { NSLog(@"Family:%@",familyname); NSArray *fontnames = [UIFont fontNamesForFamilyName:familyname]; for (NSString *name in fontnames) { NSLog(@"Font Name:%@",name); } } nt,Uint,uint16的区别及用处
在C中,既然有了int,为什么还要有uint?特别是uint16,uint32等又有什么用?他们有什么区别?”
“int是C/C++数据类型,uint,uint16,uint32并不是C/C++内建的类型,而只是一些typedef 可能的定义如下 typedef unsinged int uint;//为了省事啊,这样不用写unsignedint而只需要写uint typedef unsigned short uint16;//int的size取决于平台,比如16位平台上sizeof(16)为2,32为上为4,64位上为8 //而short的size则保证为2字节,在需要明确指明数据大小时可以使用 typedef unsigned longuint32;//道理同上,sizeof(long)一定为32,看看,在64位机上sizeof(long) ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- “大小的区别, int就是一个机器字长 uint就是一个无符号的int uint16就是一个无符号的16位整型 uint32就是一个无符号的32位整型” IOS 获取当前Wifi的SSID首先添加框架:SystemConfiguration.framework
然后引用
#import <SystemConfiguration/CaptiveNetwork.h>
- (NSString *) getDeviceSSID { NSArray *ifs = (__bridge id)CNCopySupportedInterfaces();
id info = nil; for (NSString *ifnam in ifs) { info = (__bridge id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam); if (info && [info count]) { break; } } NSDictionary *dctySSID = (NSDictionary *)info; NSString *ssid = [[dctySSID objectForKey:@"SSID"] lowercaseString]; return ssid; }
IOS添加自定义字体
准备:
字体文件(.ttf,.odf) 方法1: 添加对应的字体(.ttf或.odf)到工程的resurce,使用cocos2d中的FontLabel库,FontLabel继承于UILabel,象UILabel一样使用就好了 fontName直接使用添加的资源名字即可 方法2: 1.添加对应的字体(.ttf或.odf)到工程的resurce,例如my.ttf 2.在info.plist中添加一项 Fonts provided by application (item0对应的value为my.ttf,添加多个字体依次添加就可以了) 3.使用时 aLabel.font=[UIFont fontWithName:@"XXX" size:30]; 注意XXX不一定是my,这里是RETURN TO CASTLE, // Family name: RETURN TO CASTLE // Font name: RETURNTOCASTLE //双击,Mac下窗口的标题栏有字体的Family name,Windows下能显示Family name和Font name,下面这句用Family name和Font name都可以 self.labelTest1.font = [UIFont fontWithName:@"RETURN TO CASTLE" size:30]; 你也可以通过下面的方法遍历所有字体: 以下是代码片段: //笨办法:把字体都打印出来,找非系统字体。。。(很无语的方法) NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]]; NSArray *fontNames; NSInteger indFamily, indFont; for(indFamily=0;indFamily<[familyNames count];++indFamily) { NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]); fontNames =[[NSArray alloc]initWithArray:[UIFont fontNamesForFamilyName:[familyNames objectAtIndex:indFamily]]]; for(indFont=0; indFont<[fontNames count]; ++indFont) { NSLog(@" Font name: %@",[fontNames objectAtIndex:indFont]); } [fontNames release]; } [familyNames release]; 在程序中先加入这段代码,运行,查看console,以上程式会列出所有的字型,当然也包含UIAPPFonts所加的字型,但请注意,名字可能差距很大,要自己找一下,不是字体的文件名,弄错了将无法看到效果。 mac系统如何显示和隐藏文件
苹果Mac OS X操作系统下,隐藏文件是否显示有很多种设置方法,最简单的要算在Mac终端输入命令。显示/隐藏Mac隐藏文件命令如下(注意其中的空格并且区分大小写):
显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool true 隐藏Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool false 显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles YES 隐藏Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles NO 通常用于删除缓存的时,计算缓存大小 //单个文件的大小 -(long long) fileSizeAtPath:(NSString*) filePath{ NSFileManager* manager =[NSFileManager defaultManager]; if ([managerfileExistsAtPath:filePath]){ return [[manager attributesOfItemAtPath:filePatherror:nil] fileSize]; } return 0; } //遍历文件夹获得文件夹大小,返回多少M -(float ) folderSizeAtPath:(NSString*) folderPath{ NSFileManager* manager =[NSFileManager defaultManager]; if (![managerfileExistsAtPath:folderPath]) return 0; NSEnumerator*childFilesEnumerator = [[manager subpathsAtPath:folderPath]objectEnumerator]; NSString* fileName; long long folderSize = 0; while ((fileName =[childFilesEnumerator nextObject]) != nil){ NSString* fileAbsolutePath = [folderPathstringByAppendingPathComponent:fileName]; folderSize += [selffileSizeAtPath:fileAbsolutePath]; } returnfolderSize/(1024.0*1024.0); } 有时候需要在iOS系统里面,删除指定文件夹的内容,文件夹里面可能是文件,也可能包含有文件夹。 删除指定类型的文件。方法如下: NSFileManager
*fileManager = [
NSFileManager
defaultManager];
NSArray
*paths =
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
);
NSString
*documentsDirectory = [paths objectAtIndex:0];
NSArray
*contents = [fileManager contentsOfDirectoryAtPath:documentsDirectory error:
NULL
];
NSEnumerator
*e = [contents objectEnumerator];
NSString
*filename;
while
((filename = [e nextObject])) {
if
([[filename pathExtension] isEqualToString:extension]) {
[fileManager removeItemAtPath:[documentsDirectory stringByAppendingPathComponent:filename] error:
NULL
];
}
}
使用ASIHTTPRequest 编译提示找不到"libxml/HTMLparser.h"的解决方法使用ASIHTTPRequest xcode编译提示找不到"libxml/HTMLparser.h",解决方法如下: 1>.在xcode中左边选中项目的root节点,在中间编辑区的搜索框中输入"header search paths", 双击Header Search Paths项,点击加号增加一项并输入"${SDK_DIR}/usr/include/libxml2", 点击done按钮结束. 2>.再次在搜索框中输入"other linker flags",双击Other Linker Flags项, 点击加号增加一项并输入"-lxml2",点击done按钮结束. 好了,到此over. |
IOS 整理
最新推荐文章于 2025-07-29 17:04:03 发布