判断当前设备 是否ipad
#define isIPad UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
剪贴板
得到剪贴板
UIPasteboard *pasteboard=[UIPasteboard generalPasteboard];
把一个字符串放置到剪贴板上: //用户此后在输入框 粘贴的就是这个字符串
pasteboard.string = @"Hello World";
从剪贴板获取字符串:
UIPasteboard *pasteboard=[UIPasteboard generalPasteboard];
NSString *myString=pasteboard.string;
在iphone模拟器截屏
打开模拟器 按住ctrl键打开编辑菜单,里面会有拷贝屏幕这一项,
然后打开预览 文件-》从夹纸板新建
添加静态库
把***.a文件拖到项目的framework里面
把头文件路径添加到header search path里
拿到app的documents路径
NSString *appDocDir = [[[[NSFileManagerdefaultManager] URLsForDirectory:NSDocumentDirectoryinDomains:NSUserDomainMask] lastObject] relativePath];
另一种写法
NSString *appDocDir = [[[[NSFileManagerdefaultManager] URLsForDirectory:NSDocumentDirectoryinDomains:NSUserDomainMask] lastObject] relativePath];
NSArray *contentOfFolder = [[NSFileManagerdefaultManager] contentsOfDirectoryAtPath:appDocDir error:NULL];
for (NSString *aPath in contentOfFolder) {
NSLog(@"apath: %@", aPath);
NSString * fullPath = [appDocDir stringByAppendingPathComponent:aPath];
BOOL isDir;
if ([[NSFileManagerdefaultManager] fileExistsAtPath:fullPath isDirectory:&isDir] && !isDir)
{
[fileList addObject:aPath];
}
}
NSURL *home = [[[NSFileManagerdefaultManager] URLsForDirectory:NSDocumentDirectoryinDomains:NSUserDomainMask] lastObject];
NSURL *imaurl = [NSURLURLWithString:@"img2.jpg"relativeToURL:home];
让app支持itunes传文件
Add the
UIFileSharingEnabled
key to your application’s Info.plist
file and set the value of the key to YES
判读当前是否横向
if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
如果你的程序中用到了WiFi,想在没有有效WiFi的时候出现如图所示的提示该怎么做?
UIRequiresPersistentWiFi Boolean true
图标不要光环
UIPrerenderedIcon YES
免费程序中链接你的收费app
To send customers to a specific application: http://itunes.com/apps/appname
To send customers to a list of apps you have on the App Store:http://itunes.com/apps/developername
A tip is to use itms:// instead of http://, then it'll open in the app store directly. On the iPhone, it will make 2 (!) redirects when using http, and 1 when using itms.
White space in app name should just be removed
代码中调用safari 可实现跳转到app store!
NSURL *requestURL = [NSURLURLWithString:@"http://www.163.com"];
关闭后台运行
- 打开info.plist
- 加入 UIApplicationExitsOnSuspend 或者选择“Application does not run in background(程序不运行于后台)”
- 将其设为 YES
sadasd