下面的内容基本都是我亲测的
- Xcode目录位置:~/Library/Developer/Xcode/
- Code Snippets目录:~/Library/Developer/Xcode/UserData/CodeSnippets
- 插件安装位置:~/Library/Application Support/Developer/Shared/Xcode/Plug-ins
- profile:~/Library/MobileDevice/Provisioning Profiles
- 在 iOS 7 中,如果某个 UIViewController 的 self.view 第一个子视图是 UIScollView, 同时当这个 UIViewController 被 push 或 initWithRootController 成为 UINavigationController控制的Controller时,这个 UIViewController的 view 的子视图 UIScollView 的所有子视图, 都会被下移 64px。http://unremittingly.iteye.com/blog/2031626
- ios中json解析出现的null问题
- 下载sinippet editor:http://cocoaholic.com/snippet_edit/
- Xcode通配符:
- Bundle name: $(PRODUCT_NAME)
- Bundle identifier: $(PRODUCT_BUNDLE_IDENTIFIER)
- Git同步远程被删除的分支:git remote prune origin
- debugLog宏定义:
#ifdef DEBUG
#define DebugLog(format, ...) NSLog((@"%s [Line %d] " format), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define DebugLog(...)
#endif
- UITextView光标下移的问题:
UIViewController.automaticallyAdjustsScrollViewInsets = NO;
- UINavigationBar设置返回按钮图片
self.navigationController.navigationBar.backIndicatorImage = self.navigationController.navigationBar.backIndicatorTransitionMaskImage = [[UIImage imageNamed:@"navi_back"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- 设置naviagationBar的title字体
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithHexString:@"#333333"], NSFontAttributeName: [UIFont systemFontOfSize:16.5]}];
- separator 顶头
-(void)viewDidLayoutSubviews
{
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])
{
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])
{
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
}
- 自定义UITabBar高度:
// 在UITabBarController的子类中调用
- (void)viewWillLayoutSubviews
{
CGRect tabFrame = self.tabBar.frame; //self.TabBar is IBOutlet of your TabBar
tabFrame.size.height = kTabbarH;
tabFrame.origin.y = self.view.frame.size.height - kTabbarH;
self.tabBar.frame = tabFrame;
}
- 改变UITabBar的文字颜色
- (void)setTitleTextAttributes:(nullable NSDictionary<NSString *,id> *)attributes forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
- 给UITabBarItem添加背景色
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageWithColor:UIColorFromHex(FFDC02) size:CGSizeMake(kScreenWidth / self.viewControllers.count, kTabbarH)]];
- 改变UITabBarItem中文字的位置
[UITabBarItem appearance].titlePositionAdjustment = UIOffsetMake(0, -3);
- UITableView separatorInset
-(void)viewDidLayoutSubviews
{
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])
{
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])
{
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)])
{
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)])
{
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
- 自定义SearchBar的CancelButton
NSArray *searchBarSubViews = [[sc.searchBar.subviews objectAtIndex:0] subviews];
for (UIView *searchbuttons in searchBarSubViews)
{
if ([searchbuttons isKindOfClass:[UIButton class]])
{
UIButton *cancelButton = (UIButton *) searchbuttons;
cancelButton.enabled = YES;
cancelButton.hidden = YES;
[cancelButton setTitle:@"取消" forState:UIControlStateNormal]; //文字
[cancelButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
break;
}
}
- 改变barItem图片的位置
UIBarItem.imageInsets
- CAAnimation结束后保持最后位置
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
- 复制一个view
- (MyView *)duplicate
{
NSData * tempArchive = [NSKeyedArchiver archivedDataWithRootObject:self];
return [NSKeyedUnarchiver unarchiveObjectWithData:tempArchive];
}
- 把view生成一个image
- (UIImage *)imageWithView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, [UIScreen mainScreen].scale);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
其中[UIScreen mainScreen].scale参数可以使生成的图片更清晰。
- UIToolBar clearColor
[toolBar setBackgroundImage:[UIImage alloc] forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[toolBar setShadowImage:[UIImage alloc] forToolbarPosition:UIBarPositionAny];
约束的符号断点 UIViewAlertForUnsatisfiableConstraints
Cocoa Touch template can be found from:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Source.定制工程模板和类模板:http://www.jianshu.com/p/738d5697e869
NSURL的一些概念:
NSURL *myUrl = [NSURL URLWithString:@"search?q=uiviewcontroller"
relativeToURL:[NSURL URLWithString:@"https://www.baidu.com/"]];
NSLog(@"baseURL = %@", myUrl.baseURL); // https://www.baidu.com/
NSLog(@"path = %@", myUrl.path); // /search
NSLog(@"scheme = %@", myUrl.scheme); // https
NSLog(@"resourceSpecifier = %@", myUrl.resourceSpecifier); // search? q=uiviewcontroller
NSLog(@"relativePath = %@", myUrl.relativePath); // search
NSLog(@"relativeString = %@", myUrl.relativeString); // search? q=uiviewcontroller
NSLog(@"absoluteURL = %@", myUrl.absoluteURL); // https://www.baidu.com/search?q=uiviewcontroller
NSLog(@"absoluteString = %@", myUrl.absoluteString); // https://www.baidu.com/search?q=uiviewcontroller
- 分类添加属性:http://www.jianshu.com/p/3cbab68fb856
- 解决duplicate symbol OBJC_IVAR$ in:的方法:1. 查看项目结构里是不是有多个重复的文件 2.Build Phases -> Compile Sources里面是不是链接了多个.m
- 创建单例的写法:
/**
* 初始化方法
*/
+ (instancetype)sharedManager
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedManger = [[super allocWithZone:NULL] init];
});
return _sharedManger;
}
- (id)copyWithZone:(NSZone *)zone
{
return [YZJIMManager sharedManager];
}
+ (id)allocWithZone:(struct _NSZone *)zone
{
return [YZJIMManager sharedManager];
}
- 解决navigationBar下面的子视图不能从navationBar开始计算frame的问题:
self.edgesForExtendedLayout = UIRectEdgeNone;
- iPhone 尺寸
机型 | 像素 | 点 |
---|---|---|
6 p / 6s p | 1242 * 2208 | 414 * 736 |
6 / 6s | 750 * 1334 | 375 * 667 |
5 / 5c / 5s | 640 * 1136 | 320 * 568 |
4 / 4s | 640 * 960 | 320 * 480 |
- 动态库提交app store
为了能够顺利提交app至app store, 需要移除动态库中的x86_64和i386平台,具体操作如下:
- 进入libksygpulivedylib.framework目录,执行命令:
- lipo libksygpulivedylib -remove x86_64 -output libksygpulivedylib
- lipo libksygpulivedylib -remove i386 -output libksygpulivedylib
- 执行完成后可使用lipo -info libksygpulivedylib 命令确认当前的动态库已经移除上面两个平台。
- 如果不执行上述操作,那么在提交app store的时候,可能会出现ITMS-90087, ITMS-90209, ITMS-90125错误。
- 上架需要的资源
screen shot : 上架尺寸
iPhone4 : 640x960 或者 960x640
iPhone5 640 x 1136或者1136 x 640
iPhone6 750 x 1334 或者1334 x 750
iPhone6 plus 1242 x 2208 或者 2208x1242 (phone 6 plus实际分辨率是 1080x1920)
ipad不管是哪代 都是 768 x 1024 或者 1024 x 768
视频尺寸
3.5寸 无视频 无需上传
ipad 900x1200 或者 1200 x 900
4.7寸 750x1334 或者 1334 x 750
5.5寸和4寸都可以用 1080x1920 或者 1920 x 1080
App图标:需要1024*1024(像素)的图片
苹果客户电话:中国大陆:400 670 1855
中国香港:21129966