做项目过程中留意的一些小东西,略作记录:
//设备名称
NSString * phoneName = [[UIDevice currentDevice] systemName];
//设备系统版本
NSString * phoneVersion = [[UIDevice currentDevice] systemVersion];
//设备型号
NSString * phoneModel = [[UIDevice currentDevice] model];
//返回传入字符串的高度(指定lab的宽度求动态高度)
- (CGFloat)lab_h:(NSString *)str
{
NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
CGSize size2 = [str boundingRectWithSize:CGSizeMake(__Main_W-40, MAXFLOAT) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
return size2.height;
}
//设置navGationBar的背景图片
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"btOk2"] forBarMetrics:UIBarMetricsDefault]
//单利
static InvitationManager *sharedInstance = nil;
+ (instancetype)sharedInstance{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}(这里使用instancetype相比于id来说更好,instancetype指明返回数据为当前类对象,而id返回的时未知类型对象,这样使用instancetype就提高了编译器性能,并在编译过程中能检测出返回对象是否适用与一些方法。总结一下,instancetype的作用,就是使那些非关联返回类型的方法返回所在类的类型!)
//判断输入的字符是否全是数字的方法
- (BOOL)isPureNumandCharacters:(NSString *)string
{
string = [string stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];
if(string.length > 0)
{
return NO;
}
return YES;
}
//控制webView是返回上级页面还是返回上个网页的方法
if ([WebView canGoBack]) {
[WebView goBack];
}else
{
[self.navigationController popToRootViewControllerAnimated:YES];
}
//解决图片拉伸过程中出现的失真的问题
{
CGFloat top = 25;
CGFloat bottom = 25;
CGFloat left = 25;
CGFloat right = 25;
UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);
imageView.image = [ima.image resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];
}
//跳转到appStore
-(void)goToAppStore
{
NSString *str = [NSString stringWithFormat:
@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@",APP_STORE_ID];
if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)){
str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@",APP_STORE_ID];
}
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
//获取webView当前页面的网址
NSString * URL = webView.request.URL.absoluteString;
//隐藏webView页面的部分
[webView stringByEvaluatingJavaScriptFromString:@"var list=document.getElementsByClassName('footer');list[0].style.display='none';"];
//mjRefresh在ARC下
#pragma mjRefreash
- (void)addFooterRefrish
{
__weak typeof(UITableView) *weaktable = _public_table;
}
//上传问题
1----正在上传的文件中断或者删除,再次Submit提示:
Cannot proceed with delivery: an existing transporter instance is currently uploading this package。----------解决办法:前往/Users/bei/.itmstransporter/UploadTokens/删除目录下所有内容再次上传
//ios10适配问题小结:直接引用网络资源
http://blog.csdn.net/heyddo/article/details/52623099
cocoapods新资源https://gems.ruby-china.org