//我要自学网的java基础教程 4-2:算术运算符的分类中有分析
// i++ 先使用后对自身加一
// ++i 先对自身加1后使用
2删除数据库今天数据
[[SingleTonManager sharedInstance] openSqlite];
NSString *UUID = [[NSUserDefaults standardUserDefaults] objectForKey:@"UUID"];
int year,month,day;
NSDate *nowDate = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *comp = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit | NSDayCalendarUnit fromDate:nowDate];
year = (int)[comp year]-2000;
month = (int)[comp month];
// 获取几天是几号
day = (int)[comp day];
if ([[SingleTonManager sharedInstance].db open]) {
NSString *deleteSql = [NSString stringWithFormat:
@"delete from %@ where UUID = '%@' and Year = '%@' and Month = '%@' and Day = '%@'",
@"UserData",UUID,[NSNumber numberWithInt:year],[NSNumber numberWithInt:month],[NSNumber numberWithInt:day]];
BOOL res = [[SingleTonManager sharedInstance].db executeUpdate:deleteSql];
if (!res) {
LOG(@"删除今天数据失败");
} else {
LOG(@"删除今天数据成功");
}
[[SingleTonManager sharedInstance].db close];
}
2删除所有NSUserDefaults 存的数据
我们先要取到plist文件里的所有的Key否则 是不能用 removeObjectForKey:key这个方法来删除的,那么怎样获得plist文件中素有item的key呢,dictionary有一个方法 [dictionary allKeys];返回值是一个数组,这样我们能拿到dictionary中所有的 key,
我们知道我们写入的plist文件中的项目是以一个字典的形式保存的,所以,
代码如下:
NSUserDefaults *userDefatluts = [NSUserDefaults standardUserDefaults];
NSDictionary *dictionary = [userDefaults dictionaryRepresentation];
for(NSString* key in [dictionary allKeys]){
[userDefaults removeObjectForKey:key];
[userDefaults synchronize];
}
这样自己通过 NSUserDefaults写入到本地的plist文件就能把整个文件删除了。
2上拉刷新
_RecordTV.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
// self.page = 0;
// [self updateData];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.RecordTV.mj_footer endRefreshing];
});
}];
2设置默认语言
代码里面设置默认语言,其实我觉得设置默认语言应该是在初次填写审核资料的位置,里面有一个主要语言,主要语言设置为哪种语言,那么在没有本地话的语言环境里,就会显示这个主要语言,但是一旦你设置时弄错了,此时可以用这个方法:http://blog.csdn.net/sakulafly/article/details/11687405
UICollectionView和tableview的NSIndexPath,生成的方法是不同的。不要以为生成tableview的indexpath方法可以用来使用在UICollectionView上面!
2是12小时制,还是24小时制
[dateFormatter2 setDateFormat:@"HH:MM"];
HHMM如果字母大写,则24小时制,否则12小时制
2手势 图片移动
http://www.cnblogs.com/huangjianwu/p/4675648.html
2数据
Unknown error calling sqlite3_step (5: database is locked) eu
[[SingleTonManager sharedInstance] openSqlite];
NSString *LastConnectedPeripheralName = [[NSUserDefaults standardUserDefaults] objectForKey:@"UUID"];
LOG(@"uuid == %@",LastConnectedPeripheralName);
NSString * update = [NSString stringWithFormat:@"update UserData set IsSaveDayStatisticsData = '%@', Sleepfraction = '%@',DataType = '%@' where UUID = '%@' and Year = '%@' and Month = '%@' and Day = '%@'",@7,@99,@"天空",LastConnectedPeripheralName,@16,@7,@1];
BOOL isSuccess = [[SingleTonManager sharedInstance].db executeUpdate:update];
LOG(@"更新成功 == %d",isSuccess);
[[SingleTonManager sharedInstance].db close];
下面是错误写法,如果这样写返回的bool会是yes,但实际上并没有存入成功
executeUpdate:@"UPDATE UserData SET DataType = ? and Sleepfraction = ? and IsSaveDayStatisticsData = ? WHERE UUI
2数据库语句,降序搜索 某字段降序
FMResultSet *rs = [[SingleTonManager sharedInstance].db executeQuery:@"SELECT * FROM TrajectoryTable ORDER BY id DESC"];
[_CurrentDayHeartRateArray addObject:[TodayTempArray copy]];
2数组copy后被加进另一个数组,接着如果清空TempArray,这个另一个数组不会改变元素个数
[TodayHeartRateDataArray addObject:[TempArray copy]];
2瞬间替换某个字符串的方法
2瞬间替换某个字符串的方法:顶拦find->findand replace in workspace
2一些第三方的.a静态库缺失导致的问题
ld: warning: directory not found for option '-L/Users/hope/Documents/SVNF2/CUBOT Band/CUBOT'
ld: warning: directory not found for option '-LBand/Views'
ld: library not found for -lSocialQQ
clang: error: linker command failed with exit code 1 (use -v to see invocation)
把那些缺失的.a文件加进去就可以了;如果在这样的工程里面搜索.a文件,会发现有些是红色的,将这些文件加进去就可以了
2移动某个cell到顶部
[TableView setContentOffset:CGPointMake(0.0, (i)*44.0) animated:YES];
2隐藏返回按钮
self.navigationItem.hidesBackButton =YES;
也可以这样:
self.navigationItem.leftBarButtonItem = nil;
// [self.navigationController setNavigationBarHidden:YES];//隐藏导航
2运行instrument
运行instrument的方法,首先打开xcode上面,你需要调试的工程,然后打开instrumnet,在其左上角位置选择你要调试的iphone设备,然后点击这个设备位置紧接着的右侧,选择installed apps下面的你要调试的app,即可,然后点击左侧的红点,即是运行。
int testint = 0;
LOG(@"%@",[NSString stringWithFormat:@"%.2d",testint]);
2折线图画法
画折线图可以选择贝赛尔曲线或者coreplot,已传资源
2这个位置,引起了内存及cpu用量暴增
float XNum = runDetailData.count-1;
[afView setXNum:TodaySportArrayCount];如果这个TodaySportArrayCount换成runDetailData.count-1或者runDetailData.count,cpu及内存就会暴增,MainVC的cellforrow里面
2终端更新第三方
终端更新所有的第三方,在终端输入:cd+空格+工程路径拖进去+回车+ls(ls可不加)+pod update,它就会自动的安装或更新第三方,它是根据工程中podfile中的内容来更新的,更新完成后会看到complete字样
2装测试版注意事项
不是说他们想要测试版,就要给他们装,要会抵抗,如果还没有到稳定的版本,拒绝给他们装
2字符串字体大小
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Using NSAttributed String"];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,5)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:30.0] range:NSMakeRange(0,5)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:30.0] range:NSMakeRange(6,12)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Courier-BoldOblique" size:30.0] range:NSMakeRange(19,6)];
lbtext.attributedText = str;
2子线程 线程形成回环
http://blog.csdn.net/yuquan0821/article/details/16843195
//真正启动了timer
NSTimer *timer = [NSTimerscheduledTimerWithTimeInterval:.2target:selfselector:@selector(timerDone) userInfo:nilrepeats:YES];
//这里一定要加下面这个代码吗?虽然加了下面这一句,定时器正常使用,但是把这一句注销之后,定时器仍然正常使用!!
[[NSRunLoopcurrentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
[[NSRunLoopcurrentRunLoop] run];
2ancs断开蓝牙的处理
xTT:ANCS是系统控制的
做个提示叫用户自己去断开
或者发指令让外设看看能不能断开;先问外设能不能,
能做就协商一个指令呗
APP在app store上的链接,在电脑的itunes上取得的好于在手机上取得的。欧阳用下面的方法设置之后,又可以扫描到了
http://www.cq.xinhuanet.com/2015-01/27/c_1114140303.htm
2app状态,前台、后台、未启动
UIApplicationState state =[UIApplication sharedApplication].applicationState;
switch (state) {
case UIApplicationStateActive:
{
//前台
}
break;
case UIApplicationStateInactive:
{
//没启动app
}
break;
case UIApplicationStateBackground:
{
//后台
}
break;
default:
break;
}
nknown type name 'CGPoint'; did you mean 'Point'?
#import<CoreGraphics/CoreGraphics.h>就可以了
添加第三方的方法:在podfile(profile在工程的目录下)下面添加pod'第三方名',然后去终端cd+空格+工程路径+回车+ls(ls之后出现工程目录下的文件,为正常)+pod update(接着就会出现很多的log文字,最后又一个complete)
cornerstone 删除一个文件:仓里checkout出来的工程中删掉你要删的文件,然后在仓里面的文件(本地ip中的工程,类似192.168.1.147)也删除这个文件,然后chickout的工程submit就行
2cornerstore没更新就提交,就会出现这个问题
Some of the items in this working copy are out-of-date.
These items can't be committed until the working copy has been updated to reflect the repository's current version.
2cornerstore替换整个工程
使用cornerstore可以整个工程可以替换成另一个工程,比方说把F2替换成cubot band checkout出来的工程。
self.cameraPiker = [[UIImagePickerController alloc]init];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.cameraPiker.sourceType = UIImagePickerControllerSourceTypeCamera;
NSArray *temp_MediaTypes = [UIImagePickerController availableMediaTypesForSourceType:self.cameraPiker.sourceType];
self.cameraPiker.mediaTypes = temp_MediaTypes;
self.cameraPiker.delegate = self;
self.cameraPiker.showsCameraControls =NO;
UIToolbar *controlView = [[UIToolbar alloc] initWithFrame:CGRectMake(0,self.view.frame.size.height-44,self.view.frame.size.width, 44)];
//controlView.backgroundColor = [UIColor clearColor];
///controlView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
UIBarButtonItem * cancelItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(backCamera)];
UIBarButtonItem * takeItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(takeCamera)];
UIBarButtonItem * jianGe = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem * cameraBook = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(takeCameraBook)];///UIBarButtonSystemItemSearch
NSArray *items = [NSArray arrayWithObjects:cancelItem,jianGe,takeItem,jianGe,cameraBook,nil];
[controlView setItems:items];
self.cameraPiker.cameraOverlayView = controlView;
}
[self presentViewController:self.cameraPiker animated:YES completion:nil];
2label自适应宽度,实际是修改约束
NSString *str = @"222222222222222222222222222222222222222222";
cell.TotalDistance.text = str;
cell.TotalDistance.numberOfLines = 0;//根据最大行数需求来设置
cell.TotalDistance.lineBreakMode = NSLineBreakByTruncatingTail;
CGSize maximumLabelSize = CGSizeMake(200,9999);//labelsize的最大值
//关键语句
CGSize expectSize = [cell.TotalDistance sizeThatFits:maximumLabelSize];
float WIDTH = expectSize.width;
//别忘了把frame给回label,如果用xib加了约束的话可以只改一个约束的值
cell.TotalLabelWidthConstrant.constant = WIDTH;
2MP3格式音频,无法播放,最后用格式工厂转换格式之后解决
NSString *path = [[NSBundle mainBundle] pathForResource:@"4566" ofType:@"wav"];
2No matching provisioning profile found
Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “b705ef4a-0400-4b32-93bb-0f55e0ba0e24”, however, no such provisioning profile was found.之前提交审核要archive ipa结果一直报上面的问题,最后是pod update cocoapod之后,结合上面的博文才解决的//不过现在有更清晰简便的解决办法-》关掉所有xcode页面,点击xcode选择左上角的xcode->preferences,选择你的开发者账户,再点击view details->然后在出现的页面左下角点击download all,就可以了,重新跑,就可以archive了
2pickerview row循环显示
http://blog.csdn.net/ipromiseu/article/details/7436521
process launch failed: failed to get the task for process20990
去钥匙串里面删除掉已经失效的证书(即红色的证书),即可
2project.pbxproj冲突的解决办法
project.pbxproj冲突的解决办法:在工程目录下可以找到.xcodeproj文件,右键显示包内容,打开project.pbxproj,然后搜索mine,去除所有冲突之后,就可以了
[SVProgressHUD show];
[SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
[SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
2svp仅仅转菊花,白底黑圈
[SVProgressHUD show];
[SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
2tableview cell为nil的原因
Failed to obtain a cell from its DataSource
2team的选择
team里面如果选择自己名字的选项的话,跑完设备,会一直要你去描述文件里面信任自己的appleid,这实在是浪费时间,但是如果选择自己公司的开发者账号中的测试证书,就不会有这样的问题,所以现在我一般都是选择公司的,这样就不会有这样的问题了
2The certificate used to sign "" has either expired or has been revoked.
https://segmentfault.com/q/1010000004686346
打开“钥匙串访问”->我的证书:删除相关的证书
真机运行,Fix即可。
另外一次是wqw更换了我的team,reset后就可以了,只是选择自己名字的team时,每次安装都需要去描述文件了,点击信任,就这一点比较麻烦
另一种方法是删掉那个经常会失效的证书,然后去开发者账户重新下载一个同样的证书,也能解决问题。
2Thread 1:EXC_BREAKPOINT(code=EXC_ARM_BREAKPOINT
Thread 1:EXC_BREAKPOINT(code=EXC_ARM_BREAKPOINT,subcode=
把一个工程放在checkout出来的工程路径下,将其替换,结果就这样了,报了这样的错,但是将这个工程放在其它位置(不是checkout出来的工程路径)却可以正常跑起来。最后是cornerstone下,刷新了就可以了。很奇怪。后来iphone6plus一开始跑的时候也出现了这个闪退,在product下面clean一次之后,也可以跑了。很奇怪。
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
//CELLNUM是指一个屏幕宽度一共有几个item
[collectionView setContentOffset:CGPointMake((indexPath.section + 1-3)*(SCREEN_WIDTH/CELLNUM),0) animated:YES];
}
//实践发现下面这个方法更有效:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
[_collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
}
//但是这个方法要加下面的代码:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
}
//否则首次点击某个cell的时候将无法移动,实践是这样,没找到原因
2wifi开发
各位大牛们,问一个题外话,有没有用过wifi模块给iphone手机传送数据啊,我在网上搜了一下,这方面的资料好少你手机先要跟设备连接上吧我只看到网上有一个私有的api,可以搜索周围的wifi,但是这个应该通不过审核吧不是硬件通过wifi 跟手机通讯的,怎么又扯到搜索无线去了不是要先搜索周围的wifi才能连上wifi模块吗,就跟蓝牙通讯一样我就是想在单片机上接一个wifi模块,通过wifi模块跟iphone通讯,但是现在还没有任何思路,网上没搜到什么demo程序你做单片机需要的wifi名字和密码需要手机传给你。然后让单片机去接入网络你是做硬件的?做软件,但是老板说这个传输数据的也要归我做这样啊,懂了一点,原来我开始的思路就错了,我以为就是跟手机平常连wifi一样那你要做的就是搜索到硬件把无线密码和名称给它,等它连接到了无线会广播自己的硬件地址和相关端口号。然后你通过socket跟它交流
2xcode 7 instrument 使用
http://www.cnblogs.com/iOSv587country/p/4862989.html