使用 AudioKit,我正在尝试构建一个应用程序来分析麦克风的输入并将传入的声音分成 3 个频率范围(低、中、高)及其振幅。
这是我的代码:
class ViewController: UIViewController {
var mic: AKMicrophone!
var amplitude: AKAmplitudeTracker!
var fftTap: AKFFTTap?
var timer: Timer!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
mic = AKMicrophone()
fftTap = AKFFTTap.init(mic)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
do {
try AudioKit.start()
} catch {
AKLog("AudioKit did not start!")
}
mic.start()
timer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true, block: { (timer) in
for i in 0...256 …Run Code Online (Sandbox Code Playgroud) 我有一些UIButtons的视图.我添加另一个 - 半透明 - 视图,向用户显示一些信息(实际上,它是一种自制的模态警报).但是半透明视图下的按钮仍然会对水龙头做出反应.但他们不应该这样做.
如何防止按钮对水龙头做出反应?
我正在尝试使用谓词从NSMutableArray中获取NSDictionary:
NSMutableArray *arr = [NSMutableArray arrayWithArray:[self createArrayFromCSV:savedCSV withDelimiter:delim firstLineContainsKeys:YES]];
// The method «createArrayFromCSV returns an array of dictionaries
NSLog(@"Array %@", [arr objectAtIndex:0]); // works fine
// spits out:
// Array {
// product = "MyProduct";
// "id_product" = 29;
// }
// idField and idVal are passed to the method
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(%@ == %@)", idField, idVal];
NSLog(@"predicate %@", predicate);
// spits out predicate "id_product" == "29"
NSArray *filtered = [arr filteredArrayUsingPredicate:predicate];
NSLog(@"Filtered %@", filtered);
// Filtered is …Run Code Online (Sandbox Code Playgroud) 我试图将我的 sw.js 文件放在子目录而不是根目录中。但是后来我收到一个错误,说无法安装 service-worker。
是否真的需要将这个文件放在根目录中,或者我只是遗漏了什么?
JS代码:
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/js/pwa/sw.js', { scope: '/js/pwa' }).then(function(reg) {
console.log('Successfully registered. Scope is ' + reg.scope);
}).catch(function(error) {
console.log('Registering failed ' + error);
});
} else {
console.log('Service worker can not be registered on this device');
}
Run Code Online (Sandbox Code Playgroud) 以下代码在 iPhone 上完美运行。在后置摄像头和前置摄像头之间来回切换。然而,当在 iPad 上运行时,选择前置摄像头时canAddInput- 方法总是返回(后置摄像头工作正常)。NO有什么想法吗?
- (void)addVideoInput:(BOOL)isFront{
AVCaptureDevice *videoDevice;
//NSLog(@"Adding Video input - front: %i", isFront);
[self.captureSession removeInput:self.currentInput];
if(isFront == YES){
self.isFrontCam = YES;
videoDevice = [self frontFacingCameraIfAvailable];
}else{
self.isFrontCam = NO;
videoDevice = [self backCamera];
}
if (videoDevice) {
NSError *error;
AVCaptureDeviceInput *videoIn = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
if (!error) {
// Everything's fine up to here.
// the next line always resolves to NO and thus the
// Video input isn't added.
if ([[self …Run Code Online (Sandbox Code Playgroud) 我使用以下代码为CALayer的opacity属性设置动画:
在方法中创建动画:
+ (CABasicAnimation *)fadeIn:(float)begin duration:(float)duration remove:(BOOL)remove{
CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeAnimation.fromValue = [NSNumber numberWithFloat:0.0];
fadeAnimation.toValue = [NSNumber numberWithFloat:1.0];
fadeAnimation.additive = NO;
fadeAnimation.removedOnCompletion = remove;
fadeAnimation.beginTime = begin;
fadeAnimation.duration = duration;
fadeAnimation.fillMode = kCAFillModeBoth;
return fadeAnimation;
}
Run Code Online (Sandbox Code Playgroud)
将动画添加到图层:
[overlayLayer addAnimation:[VideoComposerHelpers fadeIn:1.0 duration:0.5 remove:NO] forKey:nil];
Run Code Online (Sandbox Code Playgroud)
这是完美的.但是,现在我想在第一个动画完成后立即向同一个图层添加另一个动画.
[overlayLayer addAnimation:[VideoComposerHelpers fadeOut:1.5 duration:0.5 remove:NO] forKey:nil]; // fadeOut is a method similar to fadeIn
Run Code Online (Sandbox Code Playgroud)
应该发生的是,图层以0.5的持续时间淡入,之后,它会以0.5的持续时间淡出.但这似乎不起作用.是因为第二个动画的起点与第一个动画的终点相同吗?
我最近升级到 Catalina 和 Xcode 11。
现在,当我尝试从组织者上传档案时,我收到一个简单的错误,提示“错误域=WorkerErrorDomain Code=-10000“上传到 App Store 时发生错误。”»
由于这不是真正的错误消息,我尝试使用xcrun altool上传 ipa。
这就是事情变得有趣的时候。这失败并出现以下错误:
Java 1.5 or Java 1.6 is required. Currently, java is the default java version. Please upgrade.
Run Code Online (Sandbox Code Playgroud)
Java 1.6 是古老的!甚至没有可用于 Catalina 的可下载软件包。
任何想法这里出了什么问题?
这是命令行工具的输出(针对路径和密码进行了编辑):
Using tool '/Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/Frameworks/AppStoreService.framework/Resources/DTAppAnalyzerExtractor'.
'DTAppAnalyzerExtractor': self.executablePath: /Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/Frameworks/AppStoreService.framework/Resources/DTAppAnalyzerExtractor
Launching: /Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/Frameworks/AppStoreService.framework/Resources/DTAppAnalyzerExtractor --input-dir /var/folders/bj/xxxxx/T/myipa.ipa --output-file /var/folders/bj/xxxxx/T/DTAppAnalyzerExtractorOutput-xxxxx.zip
Web service call (validateSoftwareSPIUsage) result: (null)
Using template named: purple-metadata-template
Sending request to iTunesTransporter...
Command: /usr/local/itms/bin/iTMSTransporter
Arguments: -m upload -u 'myusername@mydomain.com' -vp json -TxHeaders xxxxx== -sessionid xxxxx -sharedsecret xxxxx …Run Code Online (Sandbox Code Playgroud)