有没有办法从Notification-Service-Extension实例中获取保存在iOS应用程序Sandbox中的数据?我想在传递contenhandler之前从数据库中获取一些数据.
我从里面测试过
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
...
print("NotificationService didReceive UNNotificationRequest, contentHandler: \(contentHandler)")
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let filePath = "\(documentsPath)/Database.db"
print(" documentsPath: \(filePath)")
let fileManager = FileManager.default
var isDir : ObjCBool = false
if fileManager.fileExists(atPath: filePath, isDirectory:&isDir) {
if isDir.boolValue {
print(" file exists and is a directory")
} else {
print(" file exists and is a NOT a directory")
}
} else {
print("file does not exist")
}...
Run Code Online (Sandbox Code Playgroud)
对我来说,看起来扩展程序有自己的Sandbox和自己的文档文件夹. …
我是Audiokit的新手。我想可视化正在运行的AKSequencer的当前位置。是否可以连接任何回调(例如AKMetronome中的回调)或侦听器或正在运行的根时钟/主循环?还是应该使用以任何方式“触发” GUI的AKCallbackInstrument?
有谁想分享吗?谢谢!
我有一个UIBezierPath(曲线像'8',只有4个点),我需要制作一些CGPoint-Array.有任何想法吗?感谢名单!
编辑:
我有这样的bezier初始化
-(void) initBezier
{
theBezierPath = [UIBezierPath bezierPath];
[theBezierPath moveToPoint:P(211.00, 31.00)];
[theBezierPath addCurveToPoint:P(870.00, 191.00) controlPoint1:P(432.00, -11.00) controlPoint2:P(593.00, 209.00)];
[theBezierPath addCurveToPoint:P(731.00, 28.00) controlPoint1:P(1061.95, 178.53) controlPoint2:P(944.69, 5.78)];
[theBezierPath addCurveToPoint:P(189.00, 190.00) controlPoint1:P(529.00, 49.00) controlPoint2:P(450.00, 189.00)];
[theBezierPath addCurveToPoint:P(211.00, 31.00) controlPoint1:P(-33.01, 190.85) controlPoint2:P(71.00, 37.00)];
}
Run Code Online (Sandbox Code Playgroud)
我用它动画一个物体
anim = [CAKeyframeAnimation animationWithKeyPath:@"emitterPosition"];
anim.path = theBezierPath.CGPath;
anim.calculationMode = kCAAnimationCubicPaced;
anim.repeatCount = HUGE_VALF;
anim.duration = tme;
Run Code Online (Sandbox Code Playgroud)
我想逐个像素地(通过触摸位置)为路径上的对象设置动画.我希望对象将触摸的给定坐标"捕捉"到曲线上的最近点,以便沿着路径触摸滑动对象.
我需要将返回值强制转换为我需要保持动态的特定类型,例如
let cellType = "CellTypeToBeResolved"
cell = (tableView.dequeueReusableCellWithIdentifier("myID") as? CellTypeToBeResolved)!
Run Code Online (Sandbox Code Playgroud)
这怎么可能在Swift 2.0中?日Thnx!
当我想使用 AudioKit 构建振荡器时,有不同的方法可以选择。例如,您可以在 AKOperationGenerator 中创建 AKOperation,如下所示
var osc = AKOperationGenerator { parameters in
returnAKOperation.sawtoothWave(frequency: GeneratorSource.frequency)
)
Run Code Online (Sandbox Code Playgroud)
但你也可以创建一个
var oscillator = AKOscillator(waveform: AKTable(.sawtooth))
Run Code Online (Sandbox Code Playgroud)
有什么区别以及何时选择什么?谢谢!
我尝试将图像添加到面板的背景中.图像来自加载的数据.我尝试了以下代码,但没有用:
var topPanel = new Ext.Panel({
flex:1,
title:'topPanel',
style:'style="background-image: url('+this.jsonData.picURL+');'
});
Run Code Online (Sandbox Code Playgroud)
当我创建一个列表时,它与'itemTpl'配合使用.
我也试过了
style:'background-image: url({picURL});'
Run Code Online (Sandbox Code Playgroud)
和...一起
store: {
fields: ['firstName','lastName', 'picURL'],
data: this.jsondData
}
Run Code Online (Sandbox Code Playgroud)
但后来我收到了消息
[[object Object]]不是'Function.prototype.apply'的有效参数.
任何想法都可以帮助!日Thnx
我建立了自己的自定义视频播放器(编辑:在这里找到示例代码)
AVMoviePlayerView.h
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@class AVPlayer;
@interface AVMoviePlayerView : UIView
@property (nonatomic) AVPlayer *player;
- (void)setPlayer:(AVPlayer*)player;
- (void)setVideoFillMode:(NSString *)fillMode;
@end
Run Code Online (Sandbox Code Playgroud)
和
AVMoviePlayerView.m
#import "AVMoviePlayerView.h"
#import <CoreMedia/CoreMedia.h>
@implementation AVMoviePlayerView
+ (Class)layerClass {
return [AVPlayerLayer class];
}
- (AVPlayer*)player
{
return [(AVPlayerLayer*)[self layer] player];
}
- (void)setPlayer:(AVPlayer*)player
{
[(AVPlayerLayer*)[self layer] setPlayer:player];
}
- (void)setVideoFillMode:(NSString *)fillMode
{
AVPlayerLayer *playerLayer = (AVPlayerLayer*)[self layer];
playerLayer.videoGravity = fillMode;
}
@end
Run Code Online (Sandbox Code Playgroud)
在我的MainViewController.m中调用它 - (void)viewDidLoad
NSURL* url = [[NSBundle mainBundle] URLForResource:@"myVideo.264" withExtension:@"mp4"];
self.avPlayer = …Run Code Online (Sandbox Code Playgroud) 我在我的avfoundation视频播放器中循环播放视频:
NSString *loopPath = @"SubView/introCycle";
NSURL *fileURL = [[NSBundle mainBundle] URLForResource:loopPath withExtension:@"mp4"];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:fileURL options:nil];
NSString *tracksKey = @"tracks";
[asset loadValuesAsynchronouslyForKeys:@[tracksKey] completionHandler:^{
// The completion block goes here.
//NSLog(@"asset loaded asynchronously completed!");
// Completion handler block.
dispatch_async(dispatch_get_main_queue(),
^{
NSError *error;
AVKeyValueStatus status = [asset statusOfValueForKey:tracksKey error:&error];
if (![self avPlayer] && status == AVKeyValueStatusLoaded) {
if(![self playerItem]){
self.playerItem = [AVPlayerItem playerItemWithAsset:asset];
[self.playerItem addObserver:self forKeyPath:@"status" options:0 context:AVMoviePlayerViewControllerStatusObservationContext];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[self.avPlayer currentItem]];
}
self.avPlayer …Run Code Online (Sandbox Code Playgroud) 我是Java和Android开发的新手.我想在我的PhoneGap 2.2.0 Android应用程序中显示一个启动画面,但是当我添加时
super.setIntegerProperty("splashscreen", R.drawable.splash);
Run Code Online (Sandbox Code Playgroud)
到我的主类(扩展DroidGap)Eclipse抛出错误'splash无法解析或不是字段'.
我需要以pick如下动态方式使用UnderscoreJS中的方法 - 请告诉我为什么它不起作用!
var obj = {
one: '1',
two: '2',
three: '3'
};
var arr = ['one', 'two'];
var pick1 = _.pick(obj, 'one', 'two');
var pick2 = _.pick(obj, arr.toString());
console.log(pick1, pick2);
Run Code Online (Sandbox Code Playgroud)
这将返回以下内容:
Object {one: "1", two: "2"} Object {}
Run Code Online (Sandbox Code Playgroud) ios ×5
objective-c ×3
audiokit ×2
avfoundation ×2
swift ×2
akoscillator ×1
aksequencer ×1
android ×1
audio ×1
casting ×1
cgpoint ×1
coding-style ×1
cordova ×1
ios10 ×1
ios5 ×1
ipad ×1
java ×1
javascript ×1
sencha-touch ×1
swift2 ×1
uibezierpath ×1