小编tim*_*son的帖子

使用AVPlayer循环视频片段

我试图循环一段视频,给定两个帧标记(markIn和markOut).当选择循环选项时,播放器将循环播放该视频片段.我目前有一个循环用于整个视频设置使用Apple的建议,一旦到达结束发送AVPlayerItemDidPlayToEndTimeNotification.

我认为实现这一目标的一种简洁方法是在达到markOut点时发送通知,如果激活循环,​​则会将播放器移回markIn点.那么有没有办法按照playerItemDidReachMarkOut的方式创建通知?

我对通知和AVPlayer相当新,所以请原谅我,如果我错过了什么.

cocoa objective-c avfoundation nsnotificationcenter avplayer

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

检测应用程序是从Handoffs还是Universal Links启动的

是否有一种可靠/正确的方法来确定application:continueUserActivity:restorationHandler:方法中是否在我的应用程序中打开了应用程序,但我需要能够区分来源而无需向URL添加任何内容.

我查看了属性,NSUserActivity但似乎没有任何帮助,因为Handoffs和Universal Links的activityType回报NSUserActivityTypeBrowsingWeb.

那么,有没有正确的方法来做到这一点,或者我应该在不知道来源的情况下以相同的方式处理两者?

编辑:这基本上是我希望有可能实现的......

func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
    if handoff {
        ...
        return true
    } else if universalLink {
        ...
        return true
    }
    return false
}
Run Code Online (Sandbox Code Playgroud)

ios handoff ios-universal-links nsuseractivity

6
推荐指数
0
解决办法
328
查看次数

覆盖 AVPlayerViewController 中的框架手势

我希望能够在 AVKit 中使用新的 AVPlayerViewController 时更改播放控件的呈现方式。基本上,我想覆盖单指点击手势来做其他事情,并用双指点击替换该手势。我正在继承 AVPlayerViewController 以添加此功能。

我可以通过创建一个新的 UITapGestureRecognizer 来轻松添加双指点击,但通过单击执行此操作没有任何作用,因为播放控件仍然出现并且我的自定义手势方法未被调用。我假设是因为 AVPlayerViewController 有一个优先调用的手势。

我像往常一样设置手势......

// singleFingerTap: will never fire...
UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleFingerTap:)];
singleFingerTap.numberOfTouchesRequired = 1;
singleFingerTap.delegate = self;
[self.view addGestureRecognizer:singleFingerTap];

// doubleFingerTap: will work correctly...
UITapGestureRecognizer *doubleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleFingerTap:)];
doubleFingerTap.numberOfTouchesRequired = 2;
doubleFingerTap.delegate = self;
[self.view addGestureRecognizer:doubleFingerTap];
Run Code Online (Sandbox Code Playgroud)

关于如何在不访问私有属性的情况下实现这一目标的任何想法?甚至允许吗?我知道我可以使用 AVPlayer 实例创建我自己的视图控制器,然后创建我自己的播放控件,但我希望我可以在这里使用轻量级 AVKit 播放器,并进行一些简单的修改。

我试过在 AVPlayerViewController 的视图中循环手势并删除它们,但gestureRecognizers 属性为空。即使我能做到这一点,我也不知道如何添加手势以在双指点击而不是单指点击上显示播放控件。

我们欢迎所有的建议!特别是这是否可能/允许。谢谢!


编辑: 我找到了一种方法来明确解除阻止我自己的手势的玩家的私人手势。

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    id firstGesture = gestureRecognizer;
    id secondGesture = otherGestureRecognizer;

    if …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c avfoundation uigesturerecognizer ios

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

从搜索结果表(UISearchController)导航到视图(推送),并将搜索结果保留在适当的位置

我有一个搜索结果表(UISearchController),显示在导航堆栈上的视图上。我在视图上显示搜索控制器和表格,如下所示:

    _searchResultsTableViewController = [[CalendarSearchResultsTableViewController alloc] init];
_searchResultsTableViewController.delegate = self;

_searchController = [[UISearchController alloc] initWithSearchResultsController:_searchResultsTableViewController];
_searchController.delegate = self;
_searchController.hidesNavigationBarDuringPresentation = NO;
_searchController.dimsBackgroundDuringPresentation = YES;
_searchController.obscuresBackgroundDuringPresentation = YES;
_searchController.active = YES;

_searchController.searchBar.delegate = self;

UIEdgeInsets adjustForTabbarInsets = UIEdgeInsetsMake(0, 0, CGRectGetHeight(self.tabBarController.tabBar.frame), 0);
_searchResultsTableViewController.tableView.contentInset = adjustForTabbarInsets;
_searchResultsTableViewController.tableView.scrollIndicatorInsets = adjustForTabbarInsets;

[self.navigationController presentViewController:_searchController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

这将显示一个UISearchBarUINavigationBar搜索表将按预期显示。当用户从表中选择搜索结果时,我想通过在搜索结果保留在原处的情况下将其推入导航堆栈中来显示选择视图。我现在的工作方式是,显示搜索控制器的视图打开该视图,但这需要关闭搜索控制器,因为search result view出现在搜索结果表的后面。

如何使搜索控制器将推入search result view导航堆栈,从而使用户能够导航回搜索结果?

我希望它如何工作的一个示例可以在iOS Mail of Calendar应用程序中找到(搜索时)。

navigationController在搜索结果控制器中的属性为nil,因此我目前无法search result view从那里显示。

该项目在Objective-C和Swift中都可以使用,因此在其中任何一个答案都可以。任何帮助深表感谢!

objective-c ios swift uisearchcontroller

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

application:openURL:options:打开通用链接后未调用

我已经使用Branch SDK建立了通用链接。这些链接可以正确打开应用程序,并且会application:continueUserActivity:restorationHandler:被调用,但不会出现“ application:openURL:options:”

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
    Branch.getInstance().application(app, open: url, options: options)
    return true
}
Run Code Online (Sandbox Code Playgroud)

不推荐使用application:openURL:sourceApplications:annotation的也不被调用。 didFinishLaunchingWithOptionswillFinishLaunchingWithOptions两个返回true。

通过点击通用链接打开应用程序时,可能导致openURL不被调用的原因是什么?

ios swift ios-universal-links

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

在 iOS 设备上以编程方式限制 HLS 流的比特率

我有一个高清视频,正在流式传输到 iOS 应用程序。我希望允许用户能够限制最大流质量(低、中、高),考虑到以最大比特率流式传输时视频为几 GB。同样,出于明显的数据上限原因,我想自动选择基于蜂窝网络与 WiFi 连接的设置。

我可以通过访问 来获取当前比特率AVPlayerItemAccessLogEvent,但在强制使用较低质量的流时却迷失了方向。

这对于 HLS 来说是可能的吗?谢谢!

video-streaming http-live-streaming ios avplayer

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

更改 SLComposeServiceViewController 中的预览图像

我创建了一个 Safari 共享扩展,可以从当前 URL 获取特定图像。该部分已完成,但现在我尝试将 SLComposeServiceViewController 上的预览图像替换为我从 URL 中抓取的图像。我似乎找不到更改 SLComposeServiceViewController 自动生成的预览图像的方法

在此输入图像描述

我怎样才能改变这个图像?

我尝试查找 的属性inputItemsNSExtenstionContext但只能看到其中的 URL。

extension NSExtensionContext {
  for item in self.inputItems {
    if let extenstionItem = item as? NSExtensionItem {
      print("attachments = \(extenstionItem.attachments)")
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

attachments = Optional([<NSItemProvider: 0x12d513e70> {types = ( "public.url" )}])

我希望我可以更改此图像而不必创建自己的视图,因为这是我需要对默认值进行的唯一更改。

即使能够隐藏默认放置在那里的图像也会很有帮助!

ios ios8-share-extension

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

核心文本中的垂直文本对齐

编辑: 如果更具可读性,这里是以下代码的 Github 要点。

我正在编写一种使用 Core Text 在 PDF 中的矩形内绘制文本的方法。我所写的内容完成了我需要的一切,除了垂直对齐(顶部、中心、底部)。当前绘制文本的标准方式是顶部对齐,我特别需要底部对齐。

- (void)drawText:(NSString *)textToDraw inFrame:(CGRect)frameRect withFont:(UIFont *)originalFont textColor:(UIColor *)textColor alignment:(PDFTextAlignment)alignment verticalAlignment:(PDFTextVerticalAlignment)verticalAlignment {

    if (!textToDraw) {
        // If nil, give it an empty value to draw
        textToDraw = @"";
    }


    // Prepare font
    CTFontRef font = [self ctFontRefFromUIFont:originalFont];
    CGColorRef color = textColor.CGColor;

    // Paragraph
    CTTextAlignment ctAlignment;
    switch (alignment) {
        case PDFTextAlignmentLeft:
            ctAlignment = kCTTextAlignmentLeft;
            break;
        case PDFTextAlignmentCenter:
            ctAlignment = kCTTextAlignmentCenter;
            break;
        case PDFTextAlignmentRight:
            ctAlignment = kCTTextAlignmentRight;
            break;
        case PDFTextAlignmentJustified:
            ctAlignment = …
Run Code Online (Sandbox Code Playgroud)

core-graphics objective-c core-foundation core-text ios

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

如何在Android Studio的当前选项卡中打开文件

有没有办法在当前打开的文件夹中打开文件,而不是每次都在新选项卡中打开它?我基本上寻找更类似于Xcode的导航行为,其中打开的文件保存在导航堆栈中,因此我可以在同一选项卡中打开的文件之间向后/向前移动.Android studio中的默认设置似乎是每个新文件都在新选项卡中打开.

我只是问,因为我喜欢明确管理哪些标签是打开的类型,而不必在快速浏览文件后关闭标签.

谢谢!

android android-studio

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

从iOS Safari共享扩展中打开主应用程序

我有一个Safari共享扩展,我希望能够从扩展中打开主应用程序.向用户显示警报,其中他们可以选择打开应用程序.

func openAppHandler() {
    self.extensionContext?.completeRequest(returningItems: []) { (success) in
        if let url = URL(string: "myapp://...") {
            self.extensionContext?.open(url, completionHandler: nil)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

didSelectPost()调用该方法后会出现警报 ,您可以看到它出现在扩展的后台优先级完成块中.该open方法在其文档中说"在iOS 8中,只有今天的扩展点(用于创建小部件)支持这种方法." 我猜它仍然是在Safari Share Extension中仍然不支持它的情况.

有没有人知道从共享扩展中打开我的主应用程序的方法?

ios ios-extensions

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