我正试图用我的AirPlay启用AVPlayerViewController.在文件中:
https://developer.apple.com/reference/avkit/avplayerviewcontroller
它指出
AVPlayerViewController自动支持AirPlay,但您需要先执行一些项目和音频会话配置,然后才能在应用程序中启用它.
在Capabilities选项卡下,我确实启用了音频,AirPlay和画中画的背景模式.我创建了AVPlayerViewController如下:
// Create the view controller and player
let moviePlayerViewController: AVPlayerViewController = AVPlayerViewController()
let moviePlayer = AVPlayer(url: videoUrl!)
moviePlayer.allowsExternalPlayback = true
moviePlayer.usesExternalPlaybackWhileExternalScreenIsActive = true
// Initialize the AVPlayer
moviePlayerViewController.player = moviePlayer
// Present movie player and play when completion
self.present(moviePlayerViewController, animated: false, completion: {
moviePlayerViewController.player?.play()
})
Run Code Online (Sandbox Code Playgroud)
我想到了两条线
moviePlayer.allowsExternalPlayback = true
moviePlayer.usesExternalPlaybackWhileExternalScreenIsActive = true
Run Code Online (Sandbox Code Playgroud)
会添加AirPlay支持,但我错了.我已经读过AirPlay可以通过添加来使用MPVolumeView,但这是用于自定义视频控制器,而不是内置的.任何帮助将不胜感激.
我在Swift中创建了一个自定义视频播放器,AVPlayer并使用MPVolumeView了音量控制和AirPlay.视图初始化完美,但我遇到AirPlay按钮在内部消失的情况MPVolumeView.
加载视图时,MPVolumeView初始化没有问题
当用户选择使用AirPlay时,MPVolumeView移除音量滑块并仅显示AirPlay,这是预期的.
问题出现在用户关闭UIViewController然后再次打开它以播放另一个视频时.Airplay保持启用状态,这是预期的行为.当用户选择关闭AirPlay时,视频将返回到物理设备上播放,但AirPlay按钮会被隐藏.
我甚至试图showsRouteButton为我设置为true MPVolumeView,但这对此没有影响.在这种情况下,可能导致AirPlay按钮隐藏的原因是什么?只有在用户开始播放视频时启用AirPlay,然后关闭AirPlay时才会出现此问题.
我正在创建一个全屏图像库使用UICollectionView.当用户旋转设备时,我会对UICollectionView内部进行更新
func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)
我以UIViewController模态方式呈现这个并UICollectionView占据了整个屏幕.在内部viewDidLoad,我创建流程布局为:
let flowLayout = UICollectionViewFlowLayout()
flowLayout.scrollDirection = .horizontal
flowLayout.minimumInteritemSpacing = 0
flowLayout.minimumLineSpacing = 0
photosCollectionView.isPagingEnabled = true
photosCollectionView.setCollectionViewLayout(flowLayout, animated: true)
Run Code Online (Sandbox Code Playgroud)
我的大小也是:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return photosCollectionView.frame.size
}
Run Code Online (Sandbox Code Playgroud)
当我旋转设备时,viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)永远不会调用,这会导致UICollectionViewLayout不更新.当我旋转设备时,我收到消息:
The behavior of the UICollectionViewFlowLayout is not defined because: the item height must be less …Run Code Online (Sandbox Code Playgroud) collectionview ios uicollectionviewlayout swift viewwilltransitiontosize
我试图在我的localization.strings文件中放入一个Unicode字符。当我手动将标签的文本设置为“ \ u {F071}”时,字符正确显示。当我将该字符作为本地化文件中字符串的一部分时,则unicode字符不会出现我想要的样子。我可能会缺少一些编码设置吗?还是在本地化文件中不应该包含Unicode字符?
我有一个本地HTML文件,我想加载一个UIWebView,但也想在里面传递一个参数.我可以加载HTML文件
webView.loadRequest(NSURLRequest(URL: NSBundle.mainBundle().URLForResource("apprules", withExtension: "html")!))
Run Code Online (Sandbox Code Playgroud)
我想将本地传递给HTNL之类的apprules.html?lang=ja.有没有办法在Swift中这样做?
我正在使用引导选择
我已bootstrap-select使用以下方法成功导入到我的项目中:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>
<!-- (Optional) Latest compiled and minified JavaScript translation files -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/i18n/defaults-*.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
在文档<head>标签内。我想看看如何修改多个选择框中的复选标记,并认为我会尝试使用
$('.selectpicker').selectpicker('deselectAll');
Run Code Online (Sandbox Code Playgroud)
方法如图所示这里。每当我尝试使用那段代码时,都会收到一个错误:
TS2339: Property 'selectpicker' does not exist on type 'JQuery<HTMLElement>'.
Run Code Online (Sandbox Code Playgroud)
我什至尝试使用安装类型定义
npm install --save-dev @types/bootstrap-select
Run Code Online (Sandbox Code Playgroud)
但问题仍然存在。我正在使用 Visual Studio SPA 模板,该模板使用 ASP.NET Core 模板、Vue.js 和 Webpack。
我有一个UISplitViewController,其中DetailViewController包含一个UIWebView.在SplitViewController中,我有以下行
self.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible
Run Code Online (Sandbox Code Playgroud)
这使我可以随时在较大的设备中显示主视图和详细视图.我遇到的问题是当我在详细视图中打开UIWebView时,WebView的内容不会缩放以适应UIWebView的宽度.我必须缩小才能适应宽度.我想知道如何自动缩小?
在我的WebViewController的viewDidLoad中,我有:
webView.scalesPageToFit = true
webView.contentMode = UIViewContentMode.ScaleAspectFit
Run Code Online (Sandbox Code Playgroud)
我看到你可以使用webView.scrollView.zoomToRect放大.但在我看来,这是为了放大.是否有类似缩小的命令?
我试图为我添加一些透明度而NavigationBar没有任何成功.在我的内部AppDelegate's didFinishLaunchingWithOptions,我有以下几行代码:
let navigationBarAppearance = UINavigationBar.appearance()
navigationBarAppearance.barTintColor = UIColor.blueColor().colorWithAlphaComponent(0.2)
navigationBarAppearance.translucent = true
Run Code Online (Sandbox Code Playgroud)
但无论alpha组件是什么,透明度都不会改变.我甚至试图使用一种颜色UIImage:
let colorImage = UIImage.imageFromColor(UIColor.blueColor().colorWithAlphaComponent(0.2), frame: CGRect(x: 0, y: 0, width: 340, height: 64))
navigationBarAppearance.setBackgroundImage(colorImage, forBarMetrics: .Default)
Run Code Online (Sandbox Code Playgroud)
这种方法也不会改变导航栏的透明度.在我尝试的视图控制器中:
self.navigationController?.navigationBar.tintColor = UIColor.blueColor()
self.navigationController?.navigationBar.alpha = 0.2
self.navigationController?.navigationBar.translucent = true
Run Code Online (Sandbox Code Playgroud)
但仍然没有运气.任何人都可以帮我弄清楚如何在导航栏中添加透明度?
我正在创建一个DatePickerDialogFragment用户选择出生日期的地方.我想确保我能处理非格里高利的日期.我无法更改要在我的设备上使用的日历类型.Android是否为用户提供了切换日历类型的功能?如果是这样,步骤是什么?到目前为止,我在设置方面没有成功.
我想知道用户输入了多少表情符号到EditText. 如果用户只输入表情符号,并且使用 3 个或更少,我希望能够在应用程序中以更大的字体显示该字符串。
现在我确实遇到了这篇文章,它确实有助于检测字符串中是否存在表情符号,但我无法弄清楚如何计算表情符号的数量。
有谁知道如何从字符串中获取表情符号数?
我正在创建一个具有聊天功能的Apple Watch应用程序.我想在手表应用程序运行并收到APNS消息时更新聊天对话.我知道AppDelegate,功能
application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject])
Run Code Online (Sandbox Code Playgroud)
可以使用,但这只是在设备应用程序在前台运行而不是在后台运行时.在WKUserNotificationInterfaceController,有功能didReceiveRemoteNotification,但仅在使用动态通知时使用.是否可以让监视应用程序处理在不使用动态通知并且在前台运行时收到的远程通知?
push-notification apple-push-notifications ios swift watchkit
swift ×8
ios ×5
airplay ×2
android ×2
avplayer ×2
uiwebview ×2
bootstrap-4 ×1
calendar ×1
character ×1
emoji ×1
html ×1
ios8 ×1
jquery ×1
mpvolumeview ×1
translucency ×1
typescript ×1
uiscrollview ×1
unicode ×1
watchkit ×1
webpack ×1