Tag: 目标

将编码的.mp3保存到applicationStorageDirectory Adob​​e Air iOS

我正在开发一个带有Flash CS5.5 AIR v.3.1的iOS iPad应用程序 我使用ShineMp3Encoder来编码一个Wav到Mp3从: https : //github.com/kikko/Shine-MP3-Encoder-on-AS3-Alchemy 基本上,它在代码中将byteArray(wav)转换为byteArray(mp3)或“mp3encoder.mp3Data”。 我没有任何问题使用(新的FileReference())来保存。save(mp3Data,filename); 但是因为这是在一个iOS AIR应用程序中使用,我想切换到使用File.applicationStorageDirectory,以便我可以把保存的MP3放到它自己的文件夹保持组织。 当我运行代码时,它会经历所有的步骤,将wav转换为mp3,然后说它会保存,但不会有错误。 声音存储在内存中,因为它可以播放,直到应用程序closures。 我已将resolvePath更改为根文件夹myApp /,并将其更改为/ sounds – 其中没有一个可以工作。 我从来没有试图做到这一点,所以我有点迷路,为什么没有文件正在创build。 任何有任何build议的人都会帮助很多。 function onEncoded(e:Event):void{ myTI.text = "Mp3 encoded and saved. Press Play."; mp3encoder.mp3Data.position = 0; var myDate:Date = new Date(); var theDate:String = myDate.monthUTC.toString() + myDate.dayUTC.toString() + myDate.hoursUTC.toString() + myDate.minutesUTC.toString() + myDate.secondsUTC.toString(); var file:File = […]

如何在核心数据中逐组应用

我正在实现tableview,我想在tableview部分显示类名称,我正在尝试使用核心数据实现的数据库中获取类的值,我想要使用classname上的group by子句来获取数据这是我的代码 AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate]; //create managed object context NSManagedObjectContext *context = [appDelegate managedObjectContext]; NSFetchRequest* fetch = [NSFetchRequest fetchRequestWithEntityName:@"Boking_Detail"]; NSEntityDescription* entity = [NSEntityDescription entityForName:@"Boking_Detail" inManagedObjectContext:context]; NSAttributeDescription* clsName = [entity.attributesByName objectForKey:@"classname"]; NSAttributeDescription* clsDate = [entity.attributesByName objectForKey:@"classdate"]; NSAttributeDescription* startTime = [entity.attributesByName objectForKey:@"starttime"]; NSAttributeDescription* endTime = [entity.attributesByName objectForKey:@"endtime"]; NSExpressionDescription *expressionDescription = [[NSExpressionDescription alloc] init]; [expressionDescription […]

UITabbar在Xcode 6中

我有UITabbarController与4个标签在iPhone UITabbarController , UITabbarController与选项卡项目图像 但在iPhone 6和iPhone 6加上正在寻找有线。 是否需要为iPhone 6和iPhone 6加上不同的图像? 我怎样才能设置这个图像。 在iphone 6 而且, iPhone 6 Plus

我怎样才能过滤NSMutableArray由非字母字符的名字

我想过滤数组,其中名称以非字母字符开头。 我想在表视图的不同部分下显示firstName以非字母字符开头的联系人。 我尝试了下面的代码,但它崩溃了,请find下面的原因: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT(firstName BEGINSWITH[c] %@)",arrIndex]; //where arrIndex is the array of alphabetical characeters. NSArray *arrContacts = [arrayTotalContacts filteredArrayUsingPredicate:predicate]; 终止应用程序,由于未捕获的exception“NSInvalidArgumentException”,原因:'不能做一个string操作的东西不是一个string(lhs = iPhone rhs =(A,B,C,D,E,F,G,H ,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) arrayTotalContacts有以下数据: ( { firstName = iPhone; lastName = ""; }, { firstName = Madhu; lastName = ""; }, { firstName = "Swa"; lastName = ""; }, […]

我怎样才能用这个简单的while循环使用NSTimer?

我有一个 – (void)方法正在执行,并在一个点上得到一个while循环,直接从加速度计获取值的那一刻 我在整个关于NSTimer类的文档中进行了讨论,但我无法理解我在这种情况下如何使用这个对象: 例如 -(void) play { …… … if(accelerationOnYaxis >0 && accelerationOnYaxis < 0.9 ) { startTimer; } while(accelerationOnYaxis >0 && accelerationOnYaxis < 0.9) { if(checkTimer >= 300msec) { printOut_AccelerationStayedBetweenThoseTwoValuesForAtLeast300msecs; break_Out_Of_This_Loop; } } stopTimerAndReSetTimerToZero; ….. more code… …. … } 任何帮助?

为什么当我为我的CABasicAnimation设置一个较低的持续时间值时,它会跳转吗?

示例项目: http : //cl.ly/1W3V3b0D2001 我使用CABasicAnimation来创build一个像饼图一样的进度指示器。 类似于iOS 7的应用程序下载animation: animation设置如下: – (void)drawRect:(CGRect)rect { [super drawRect:rect]; CGFloat radius = CGRectGetWidth(self.frame) / 2; CGFloat inset = 1; CAShapeLayer *ring = [CAShapeLayer layer]; ring.path = [UIBezierPath bezierPathWithRoundedRect:CGRectInset(self.bounds, inset, inset) cornerRadius:radius-inset].CGPath; ring.fillColor = [UIColor clearColor].CGColor; ring.strokeColor = [UIColor whiteColor].CGColor; ring.lineWidth = 2; self.innerPie = [CAShapeLayer layer]; inset = radius/2; self.innerPie.path = […]

如何调整文字(字体)以适应UISegmentedControl的UISegment?

有没有什么办法可以缩小UISegmentedControl单个部分的字体大小? 已经尝试了很多东西, [[UILabel appearanceWhenContainedIn:[UISegmentedControl class], nil] adjustsFontSizeToFitWidth]; [[UILabel appearanceWhenContainedIn:[UISegmentedControl class], nil] setMinimumScaleFactor:0.5]; 和 NSArray *arr = segment.subviews; // segment is UISegmentedControl object for (int i = 0; i < arr.count; i++) { UIView *aSegment = [arr objectAtIndex:i]; for (UILabel *label in aSegment.subviews) { if ([label isKindOfClass:[UILabel class]]) { UILabel *myLabel = (UILabel *)label; [myLabel setNumberOfLines:0]; […]

iOS lazy var UIBarButtonItem目标问题

当使用lazy var初始化时,我无意识地发现了这个UIBarButtonItem目标问题。 class ViewController: UIViewController { lazy var barButtonItem1 = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(action1)) lazy var barButtonItem2: UIBarButtonItem = { let barButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(action2)) return barButtonItem } override func viewDidLoad() { super.viewDidLoad() print(barButtonItem1.target, barButtonItem2.target) } } 打印结果显示barButtonItem1.target为零,而barButtonItem2.target为自己,这看起来很疯狂! 当我使用barButtonItem1的lazy var写入时,我得到了这个问题,然后我发现barButtonItem1的动作永远不会被调用,最后问题是barButtonItem1.target为零。 我不知道为什么会发生这种情况,但是我很确定这是一个错误。 有没有人知道这件事? 如果你能解释一下,我会非常感激。

快速替代互斥

我有多个线程之间的共享内存。 我想阻止这些线程同时访问这块内存。 (如生产者 – 消费者问题) 问题 : 一个线程将元素添加到队列中,另一个线程读取这些元素并将其删除。 他们不应该同时访问队列。 解决这个问题的一个办法是使用Mutex。 正如我所发现的,Swift中没有互斥体。 Swift中有没有其他的select?

AVAssetExportSession失败 – 合并2个WAV文件(iOS7)

我试图合并2个WAV文件,使用AVAssetExportSession,在iOS7下。 我已经确认文件在那里,似乎并没有腐败或任何东西。 这些WAV文件是从设备本身的录制文件中提取的,而且是相对较小的文件。 调用exportAsync方法时,立即在完成块中立即出现“Operation Stopped”错误(原因描述为:“此操作不支持此介质”)。 这发生在模拟器和设备本身。 见下面我的导出代码: NSError *avError = nil; NSFileManager *fileManager = [NSFileManager defaultManager]; AVURLAsset *tmpAsset = [[AVURLAsset alloc] initWithURL:_tmpRecordingUrl options:@{AVURLAssetPreferPreciseDurationAndTimingKey: @YES}]; AVURLAsset *permAsset = [[AVURLAsset alloc] initWithURL:_url options:@{AVURLAssetPreferPreciseDurationAndTimingKey: @YES}]; AVMutableComposition *composition = [AVMutableComposition composition]; [composition insertTimeRange:CMTimeRangeMake(kCMTimeZero, permAsset.duration) ofAsset:permAsset atTime:kCMTimeZero error:&avError]; [composition insertTimeRange:CMTimeRangeMake(kCMTimeZero, tmpAsset.duration) ofAsset:tmpAsset atTime:CMTimeMakeWithSeconds(_positionSlider.value, 1) error:&avError]; AVAssetExportSession *export = [[AVAssetExportSession alloc] […]