一、跳转到AppStore给App评分
有一些APP有给App评分,或者分享APP给好友的功能,需要跳转到AppStore,其URL为:
[[UIApplication sharedApplication] openURL : [ NSURL URLWithString : @"itms://itunes.apple.com/gb/app/yi-dong-cai-bian/idxxxxxxxxx?mt=8" ]];
xxxxxxxxx:为自己App在AppStore中的APP ID
二、创建PCH文件
1、Commond + N
2、Other -->PCH File
3、Build Settings -->搜 Prefix Header
4、配置 $(SRCROOT)/工程名/PCH名字.pch
例:$(SRCROOT)/RCTCost/RCTCost-Prefix.pch
三、图片旋转
UIImage *image1 = [UIImage imageNamed:@"arrow.png"];
转换成 CGImageRef形式
CGImageRef cgImage = image1.CGImage;
其中参数含义:
imageWithCGImage:CGImageRef样式的图片
scale:此参数意思还没理解(有知道的,欢迎留言,小弟不胜感激)
orientation:图片要旋转的方向(枚举类型,点进去看)
arrowImgView.image = [UIImage imageWithCGImage:cgImage scale:1 orientation:UIImageOrientationRight];
四、计算两个方法执行时间差
NSDate *date1 = [NSDate date];
NSDate *date2 = [NSDate date];
NSTimeInterval aTime = [_date2 timeIntervalSinceDate: _date1];
NSLog(@"A与B之间相差%.3f秒",aTime);
五、跳转到指定界面
注:
1、此方法写在你返回按钮的点击事件中
2、YPHomePageController是你要跳转的Controller
UINavigationController *navVC = self.navigationController;
NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
for( UIViewController *vc in [navVC viewControllers] ) {
[viewControllers addObject: vc];
if([vc isKindOfClass:[YPHomePageController class]]) {
break;
}
[navVC setViewControllers:viewControllers animated:YES];
六、禁止界面左侧滑动返回前一个界面
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled =NO;
}
七、设置透明导航栏
- (void)viewWillAppear:(BOOL)animated{
//设置导航栏背景图片为一个空的image,这样就透明了
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
//去掉透明后导航栏下边的黑边
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
}
- (void)viewWillDisappear:(BOOL)animated{
//如果不想让其他页面的导航栏变为透明 需要重置
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];
}