我正在iOS中构建一个应用程序,我希望我的CollectionView中的单元格在触摸时突出显示,就像普通按钮一样.如何在didSelectItemAtIndexPath:(NSIndexPath*)indexPath方法中实现此目的?
我有这段代码可以将视频的大小从 1280 x 720 调整为 640 x 360 但我想要一个不裁剪的调整大小。
有没有办法完全调整不裁剪的大小?
这是代码
class func resizer(inputURL : NSURL , completion: (outPutURL : NSURL?) -> Void ){
let videoAsset = AVAsset(URL: inputURL) as AVAsset
let clipVideoTrack = videoAsset.tracksWithMediaType(AVMediaTypeVideo).first! as AVAssetTrack
let composition = AVMutableComposition()
composition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: CMPersistentTrackID())
let videoComposition = AVMutableVideoComposition()
videoComposition.renderSize = CGSizeMake(360,640)
videoComposition.frameDuration = CMTimeMake(1, 30)
let instruction = AVMutableVideoCompositionInstruction()
instruction.timeRange = CMTimeRangeMake(kCMTimeZero, CMTimeMakeWithSeconds(180, 30))
let transformer : AVMutableVideoCompositionLayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: clipVideoTrack)
let t1 = CGAffineTransformMakeTranslation(360, 0)
let t2 = CGAffineTransformRotate(t1, …Run Code Online (Sandbox Code Playgroud) 我收到以下有关将代码更新为Swift 4的警告
隐式的Objective-C入口点-[development.ASTodayViewController tableView:heightForHeaderInSection:]已过时,并将在Swift 4中删除
如何解决呢?
我有表委托方法
func tableView(_ tableView: UITableView,
heightForHeaderInSection section: Int) -> CGFloat {
return 40.0
}
Run Code Online (Sandbox Code Playgroud) 在我的iOS应用程序中,当用户点击UITextfield我需要自动将键盘视图更改为数字视图时.我写下面的代码,它工作正常.
UITextField *txtfield = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
txtfield.keyboardType = UIKeyboardTypeNumberPad;
Run Code Online (Sandbox Code Playgroud)
我的app支持本地化.我在设备上添加了4个键盘,如英语,西班牙语,印地语,表情符号.我想在数字键盘类型中禁用或隐藏本地化.请参阅附图.我用红框突出显示.
谁知道怎么做?
在使用Xcode 8.2的swift 3中,我无法reusableHeaderView显示UICollectionView.我在标题视图文件的不同位置放置断点,它们永远不会被触发.这是我的代码.
import UIKit
class WishListViewController: UIViewController,
UICollectionViewDelegateFlowLayout,
UICollectionViewDataSource {
var collectionView: UICollectionView!
var wishListItems = [[String:Any]]()
var shops = [[String: Any]]()
let cellId = "WishListCell"
let headerId = "WishListHeaderView"
var screenSize: CGRect!
var screenWidth: CGFloat!
var screenHeight: CGFloat!
let imageAspectRatio: CGFloat = 1.2
override func viewDidLoad() {
super.viewDidLoad()
screenSize = UIScreen.main.bounds
screenWidth = screenSize.width
screenHeight = screenSize.height
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) …Run Code Online (Sandbox Code Playgroud) 在我们的项目中,我们指定
hidesNavigationBarDuringPresentation = false
Run Code Online (Sandbox Code Playgroud)
在某人UIViewController的身上UISearchController。searchController具有一系列范围标题。到目前为止,它在iOS 10上都可以正常运行,但是在iOS 11 beta中,似乎hidesNavigationBarDuringPresentation的错误设置被忽略,使显示混乱。为确保不是我项目中的其他因素,我创建了一个仅有一个项目的准系统测试项目UITableViewController,并UISearchController使用另一个simple 进行了初始化UITableViewController。以下代码位于viewDidLoad()主视图控制器上的方法中:
self.title = "Search Bar Scope Test"
let searchViewController = SearchViewController(style: .plain)
searchController = UISearchController(searchResultsController: searchViewController)
searchController!.searchBar.sizeToFit()
tableView.tableHeaderView = searchController!.searchBar
searchController?.hidesNavigationBarDuringPresentation = false
searchController?.searchBar.scopeButtonTitles = ["scope 1", "scope 2", "scope 3", "scope 4", "scope 5"]
Run Code Online (Sandbox Code Playgroud)
当最后一行分配scopeButtonTitles不存在时,导航栏不会隐藏,搜索栏仍保持其原始位置。但是,在存在该行的情况下,iPhone和iPad上的都NavigationBar变为隐藏状态,searchBar加号和范围按钮在纵向模式下都向上移动,而在横向模式下保持不变(即使范围按钮很多并且不能一起使用)线)。
有人遇到过吗?这是iOS 11中的错误或预期行为(虽然不是我们的预期行为),并且有任何解决方法吗?
谢谢!
我已经在iTunes上发布了iOS应用程序的更新。它在App Store上可用,但既没有显示在“更新”选项卡中,也没有自动更新。最后,我从应用商店中卸载了旧版本并安装了新版本。此iOS应用程序是在phonegap中开发的。
我正在考虑使用uuid来区分我的swift应用程序,并在网上查看如何实现它.在搜索时,我经常发现人们将uuid小写为:
let uuid = NSUUID().UUIDString.lowercaseString
Run Code Online (Sandbox Code Playgroud)
是不是不需要降低uuid的包装或减少随机性?
我正在尝试使用Swift 4.0开发非常简单的Xcode OS X程序-该程序可以构建并运行,但是访问URL视频文件时出现错误。可能与某处的特权或安全设置有关,但无法确定该位置。这是我在ViewController类下的程序:NSViewController:
@IBOutlet var playerView: AVPlayerView!
//var url: URL!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// guard let url = URL(string: "https://devimages.apple.com.edgekey.net/samplecode/avfoundationMedia/AVF oundationQueuePlayer_HLS2/master.m3u8")
// else {
// return
// }
let url1 = URL(string: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4")
let player = AVPlayer(url: url1!)
// Create a new AVPlayer and associate it with the player view
let playerView = self.playerView
playerView?.player = player
playerView?.player!.play();
}
Run Code Online (Sandbox Code Playgroud)
另外,我还使用以下内容修改了info.plist文件:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
<key>NSExceptionDomains</key>
<dict/> …Run Code Online (Sandbox Code Playgroud) ios ×5
swift ×5
iphone ×2
xcode ×2
avfoundation ×1
avplayer ×1
cells ×1
highlight ×1
ios11 ×1
objective-c ×1
swift3 ×1
swift4 ×1
uisearchbar ×1
uuid ×1
xcode9-beta ×1
xcode9beta6 ×1