我有一个电子邮件的字符串.无论字符串/电子邮件是什么,我希望能够获得电子邮件的域名部分.基本上我想要在字符串的@部分之后抓住字符.例如,对于testing@kotlin.com,我在kotlin.com部分之后.
val emailString ="hello@world.com"
我有一个简单的UICollectionViewController,它返回X个单元格.我想拥有它,所以当选择一个单元格时,特定的选定单元格将改变它的大小并变得更大,因为所有其他单元格保持不变.我该如何实现这一目标?这是我的代码:
class HomeController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
let cellId = "cellId"
override func viewDidLoad() {
super.viewDidLoad()
collectionView?.backgroundColor = UIColor(white: 0.90, alpha: 1.0)
collectionView?.register(PostCell.self, forCellWithReuseIdentifier: cellId)
collectionView?.showsVerticalScrollIndicator = false
collectionView?.alwaysBounceVertical = true
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 4
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as! PostCell
return cell
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize …Run Code Online (Sandbox Code Playgroud) uicollectionview uicollectionviewcell uicollectionviewlayout swift swift3
我真的很难让图像或文本真正成为我的视频的一部分,类似于 Snapchat 添加文本/贴纸功能。我不希望它只是位于我的视频之上,而是实际上位于视频本身上,以便在保存时它会显示。任何帮助将受到高度赞赏并标记为答案。多谢你们。代码如下...
import UIKit
import AVFoundation
import AVKit
import Photos
class VideoViewController: UIViewController {
override var prefersStatusBarHidden: Bool { return true }
var videoURL: URL
var player: AVPlayer?
var playerLayer: AVPlayerLayer?
init(videoURL: URL) {
self.videoURL = videoURL
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
UIApplication.shared.keyWindow?.backgroundColor = .black
self.view.backgroundColor = .black
self.player = AVPlayer(url: videoURL)
self.playerLayer = AVPlayerLayer(player: self.player)
self.playerLayer?.frame = self.view.frame
self.playerLayer?.backgroundColor = UIColor.black.cgColor
self.view.layer.addSublayer(playerLayer!) …Run Code Online (Sandbox Code Playgroud) 我有一个UICollectionView有一堆单元格.当我选择这些单元格时,它们会改变颜色,看起来好像已经明确选择了,我将hashtag.hashtag_name(String)附加到我的hashtagsArray.如果我点击一个类别(时尚,食物,爱好或音乐),我会将另一个数组附加到该索引路径,以便为用户提供该特定类别的单元格,如下图所示.
我想要的是,如果我将已经SELECTED的单元格点击为UNSELECT它,那么hashtag.hashtag_name将从我的hashtagArray中删除.问题是,当我将其添加到hashtagArray中时,我添加的数组的indexPath与数组indexPath完全不同,因此我无法通过调用将其删除self.hashtagArray.remove(Int).这是我的代码......

import UIKit
class Hashtag: NSObject {
var hashtag_name: String?
var hashtag_color: String?
}
import UIKit
private let reuseIdentifier = "Cell"
class HashtagView: UICollectionViewController, UICollectionViewDelegateFlowLayout {
var hashtagArray: [String] = []
var categoriesArray = [Hashtag]()
var fashionArray = [Hashtag]()
var isFashionSelected: Bool = false
var fashionArrayCount: [Int] = []
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.tintColor = .white
navigationItem.title = "Hashtag"
self.collectionView?.backgroundColor = .white
self.collectionView?.register(HashtagCell.self, forCellWithReuseIdentifier: reuseIdentifier)
self.collectionView?.contentInset = UIEdgeInsetsMake(10, 0, 0, 0)
handleFetchCategories()
handleFetchFashionHashtags()
}
func insertCategoryAtIndexPath(element: …Run Code Online (Sandbox Code Playgroud) 我正在使用地图,并且在模拟器上运行它时,该地图将无法工作。在我的日志中,我收到一条错误消息,告诉我必须授予对ACCESS_FINE_LOCATION的访问权限。如何在KOTLIN中做到这一点?我只能在使用Java的S / O上找到答案。我得到的错误是:
位置提供者需要ACCESS_FINE_LOCATION权限