小编hea*_*kit的帖子

iOS:如何从其UNNotificationServiceExtension中获取应用程序的已保存数据?

有没有办法从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和自己的文档文件夹. …

ios ios10 serviceextension

5
推荐指数
1
解决办法
995
查看次数

如何使用Audiokit可视化AKSequencer当前位置?

我是Audiokit的新手。我想可视化正在运行的AKSequencer的当前位置。是否可以连接任何回调(例如AKMetronome中的回调)或侦听器或正在运行的根时钟/主循环?还是应该使用以任何方式“触发” GUI的AKCallbackInstrument?

有谁想分享吗?谢谢!

audio ios swift audiokit aksequencer

5
推荐指数
1
解决办法
349
查看次数

如何从UIBezierPath生成CGPoint-Array(沿给定路径触摸滑动对象)

我有一个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)

我想逐个像素地(通过触摸位置)为路径上的对象设置动画.我希望对象将触摸的给定坐标"捕捉"到曲线上的最近点,以便沿着路径触摸滑动对象.

objective-c cgpoint ios uibezierpath

4
推荐指数
1
解决办法
4379
查看次数

如何动态转换为使用Swift 2.0在字符串中命名的Type?

我需要将返回值强制转换为我需要保持动态的特定类型,例如

let cellType = "CellTypeToBeResolved"
cell = (tableView.dequeueReusableCellWithIdentifier("myID") as? CellTypeToBeResolved)!
Run Code Online (Sandbox Code Playgroud)

这怎么可能在Swift 2.0中?日Thnx!

casting dynamic-typing ios swift2

4
推荐指数
1
解决办法
1061
查看次数

AudioKit:何时使用 AKOperationGenerator 或 AKOscillator?

当我想使用 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)

有什么区别以及何时选择什么?谢谢!

ios swift audiokit akoperationgenerator akoscillator

4
推荐指数
1
解决办法
622
查看次数

sencha touch ::将背景图像添加到Panel

我尝试将图像添加到面板的背景中.图像来自加载的数据.我尝试了以下代码,但没有用:

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

coding-style background-image sencha-touch

1
推荐指数
1
解决办法
1万
查看次数

为什么我的视频在模拟器中播放但在使用AVFoundation Videoplayer的设备(iPad)上播放?

我建立了自己的自定义视频播放器(编辑:在这里找到示例代码)

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)

objective-c avfoundation ipad ios-simulator ios5

1
推荐指数
1
解决办法
2484
查看次数

当我在使用AVFoundation时重新加载视图时,为什么我的playerItemDidReachEnd-method被触发了两次?

我在我的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)

objective-c avfoundation

1
推荐指数
1
解决办法
2219
查看次数

PhoneGap 2.2.0 Android SplashScreen - 投掷错误'启动无法解决或不是字段'

我是Java和Android开发的新手.我想在我的PhoneGap 2.2.0 Android应用程序中显示一个启动画面,但是当我添加时

 super.setIntegerProperty("splashscreen", R.drawable.splash);
Run Code Online (Sandbox Code Playgroud)

到我的主类(扩展DroidGap)Eclipse抛出错误'splash无法解析或不是字段'.

java android splash-screen cordova

1
推荐指数
1
解决办法
3912
查看次数

如何动态使用pick() - 方法形成UnderscoreJS

我需要以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)

javascript underscore.js

1
推荐指数
1
解决办法
765
查看次数