我想从UIImagepicker中选择一个图像,在相机胶卷中有PNG和JPG格式.
我需要将其转换为NSData.不过,我需要知道这是图像UIImageJPEGRepresentation还是UIImagePNGRepresentation,所以我可以将其转换.
UIImage *orginalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
[picker dismissViewControllerAnimated:YES completion:nil];
NSData *orgData = UIImagePNGRepresentation(orginalImage);
Run Code Online (Sandbox Code Playgroud) iphone xcode uiimagejpegrepresentation ios uiimagepngrepresentation
我想用CHCSVParser我的核心数据导出到CSV.我知道如何从实体获取所有价值,但我不知道如何写入CSV.
任何人都可以教我如何用CSV写入CHCSVParser?
// Test listing all Infos from the store
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"NoteLog" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
for (NoteLog *noteInfo in fetchedObjects) {
NSLog(@"Name: %@", noteInfo.city );
NSLog(@"Name: %@", noteInfo.country);
NSLog(@"Name: %@", noteInfo.datetime);
NSLog(@"Name: %@", noteInfo.notelatitude);
NSLog(@"Name: %@", noteInfo.notelongtitude);
NSLog(@"Name: %@", noteInfo.state);
NSLog(@"Name: %@", noteInfo.text);
}
Run Code Online (Sandbox Code Playgroud) 我不得不将大文件大小的歌曲从iTunes库转换为较小的8K歌曲文件.
当我执行转换异步时,即使写入doc文件夹未完成,bool也总是返回true.目前我正在使用10秒的延迟再次调用该功能,它在iPhone 5s的临时工作正常,但我想迎合较慢的设备.
请在我的代码上给我一些指针/推荐.
-(void)startUploadSongAnalysis
{
[self updateProgressYForID3NForUpload:NO];
if ([self.uploadWorkingAray count]>=1)
{
Song *songVar = [self.uploadWorkingAray objectAtIndex:0];//core data var
NSLog(@"songVar %@",songVar.songName);
NSLog(@"songVar %@",songVar.songURL);
NSURL *songU = [NSURL URLWithString:songVar.songURL]; //URL of iTunes Lib
// self.asset = [AVAsset assetWithURL:songU];
// NSLog(@"asset %@",self.asset);
NSError *error;
NSString *subString = [[songVar.songURL componentsSeparatedByString:@"id="] lastObject];
NSString *savedPath = [self.documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"audio%@.m4a",subString]];//save file name of converted 8kb song
NSString *subStringPath = [NSString stringWithFormat:@"audio%@.m4a",subString];
if ([self.fileManager fileExistsAtPath:savedPath] == YES)
[self.fileManager removeItemAtPath:savedPath error:&error];
NSLog(@"cacheDir %@",savedPath);
//export low bitrate song to …Run Code Online (Sandbox Code Playgroud) objective-c nsdocument ios avassetwriter avassetexportsession
我在图像视图中有5个动画图像,并希望允许用户根据默认ID点击它们并将其推送到另一个视图.我试图添加手势点击,但imageview没有检测到.
任何人都可以给我一些建议吗?
编辑:最后我没有使用它,我设置了一个UIButton.
谢谢 :)
viewDidLoad中
self.defaultID = [[NSMutableArray alloc] initWithObjects:@"7",@"9",@"11",@"27",@"6",nil];
self.defaultImageCaption = [[NSMutableArray alloc] initWithObjects:@"Ver",@"Green",@"Red",@"CF",@"Dwarf",nil];
//default image
imageViewTop.alpha = 1.0;
imageViewBottom.alpha = 0.0;
imageViewBottom = [[UIImageView alloc] initWithFrame:CGRectMake(0,44,320,367)];
imageViewTop = [[UIImageView alloc] initWithFrame:CGRectMake(0,44,320,367)];
singleDefaultTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleDefaultTap:)];
singleDefaultTap.numberOfTouchesRequired = 1;
imageViewTop.userInteractionEnabled = YES;
[imageViewTop addGestureRecognizer:singleDefaultTap];
imageViewTop.tag = 2000;
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0,44,320,367)];
[topView addSubview:imageViewTop];
[self.view addSubview:imageViewTop];
[self.view addSubview:topView];
[self.view addSubview:imageViewBottom];
[self nextAnimation]
Run Code Online (Sandbox Code Playgroud)
-(void)nextAnimation{
//picture loop
imageViewTop.image = imageViewBottom.image;
imageViewBottom.image = [imageArray objectAtIndex:[imageArray count] - 1];
[imageArray …Run Code Online (Sandbox Code Playgroud) 我想知道如何在附加图像中执行双滑块.
我正在看这个代码来修改它.我想知道如何让2个滑块允许用户选择所需的时间.
我遇到的问题是我如何有2个滑块来显示像图像?
http://www.cocoacontrols.com/controls/tb_circularslider
任何评论都非常感谢.

我有这个查询来显示
有2张桌子,我将从表格翻新中获得翻新的数量,而客户ID和名称来自表1,客户.

SELECT c.[Customer-ID], c.name, COUNT(*)"Number of Renovation"
FROM CUSTOMER c, RENOVATION r
WHERE c.[Customer-ID] = r.[Customer-ID]
GROUP BY c.[Customer-ID], c.name
HAVING Count(*) in
(SELECT COUNT(*) FROM RENOVATION GROUP BY [Customer-ID])
ORDER BY c.[customer-id]
Run Code Online (Sandbox Code Playgroud)
这不是我查询的正确方法,任何人都知道如何缩短查询?或其他方式吗?虽然它仍然找到答案.我顺便学习SQL服务器.
我有一些KML数据定义了地图上的区域,如下所示:
131.0764742247829,-15.80786022929951,0 132.6357700620065,-16.54895727734661,0
134.1119108999971,-17.28040233069844,0 135.8545033459996,-18.1298170074137,0
137.7396886168202,-19.07860187595016,0 140.011948401144,-20.18462043802856,0
142.3114600417346,-21.19369381963822,0 144.1566045495202,-22.15731684591415,0
Run Code Online (Sandbox Code Playgroud)

我想在我的iOS应用程序中确定用户的当前位置是否在此定义区域内.我怎样才能做到这一点?
编辑:我将arc4random()替换为arc4random_uniform()以进行修复
我正在使用试飞来监控崩溃.一直在修复bug,但是我遇到了这个bug,我不知道为什么索引这么大.
-[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds for empty array
Run Code Online (Sandbox Code Playgroud)
很可能这就是bug的地方
for (NSUInteger i = 0; i < count; ++i) {
// Select a random element between i and end of array to swap with.
int nElements = count - i;
int n = (arc4random() % nElements) + i;
[randomName exchangeObjectAtIndex:i withObjectAtIndex:n];
[randomImgName exchangeObjectAtIndex:i withObjectAtIndex:n];
[randomID exchangeObjectAtIndex:i withObjectAtIndex:n];
}
Run Code Online (Sandbox Code Playgroud)
这引起了崩溃
//Frog Name Caption
NSString * tempCaption = [defaultFrogImageCaption objectAtIndex:[defaultFrogImageCaption count]-1];
self.dFrogID = [defaultFrogID objectAtIndex:[defaultFrogID count]-1];
Run Code Online (Sandbox Code Playgroud)
我相信这是错误,但我不知道如何解决错误.
感谢所有的评论和帮助
-(void)defaultFrogSetup
{ …Run Code Online (Sandbox Code Playgroud) 我厌倦了查看SF的解决方案,但无法找到解决方案.也许我错过了请帮助.
我试图通过循环遍历所有KML来检查用户精确定位多边形.这个应用总是崩溃@这一点:
[mapView addOverlay:overlayPolygon];
// zoom the map to the polygon bounds
[mapView setVisibleMapRect:overlayPolygon.boundingMapRect animated:YES];
Run Code Online (Sandbox Code Playgroud)
问题代码:
//create KML in hidden Mapview
-(void)loadKML:(NSMutableArray *)kmlNameArray
{
//dispatch_group_t group = dispatch_group_create();
//remove polygon and redraw again.
[NSThread detachNewThreadSelector: @selector(spinEnd) toTarget:self withObject:nil];
[mapView removeOverlays:mapView.overlays];
[inUserRangeArray removeAllObjects];
[inUserRangeArrayObjectIndex removeAllObjects];
[scrollview removeFromSuperview];
[pageControl removeFromSuperview];
[NSThread detachNewThreadSelector: @selector(spinBegin) toTarget:self withObject:nil];
NSArray *sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
NSString *docDirectory = [sysPaths objectAtIndex:0];
for (int e=0; e<[kmlNameArray count]; e++)
{
//NSString *kmlNameStr = [kmlNameArray objectAtIndex:e];
Frog *kmlID …Run Code Online (Sandbox Code Playgroud) 我试图根据初始查询的情绪来预测我的coredate所有情绪设置为8.我将每秒从0到7调用以更新tableview.
但我明白了
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't use in/contains operator with collection 8 (not a collection)'
Run Code Online (Sandbox Code Playgroud)
我应该使用CONTAINS或其他运算符来谓词吗?
NSString* filter = @"%K CONTAINS[cd] %@";
NSPredicate *getMoodPred = [NSPredicate predicateWithFormat:filter, @"mood", mood];
NSLog(@"getmood %@",getMoodPred); //getmood mood CONTAINS[cd] "7"
NSArray *getMoodArray = [[VPPCoreData sharedInstance]allObjectsForEntity:@"Song" orderBy:Nil filteredBy:getMoodPred];
Run Code Online (Sandbox Code Playgroud) ios ×9
iphone ×8
xcode ×5
objective-c ×2
arc4random ×1
core-data ×1
nsdocument ×1
nspredicate ×1
sql ×1
sql-server ×1
uianimation ×1
uislider ×1