我正在尝试将模式ViewController中的数据传递给他的源ViewController.我想我必须使用委托,但它不起作用.
protocol communicationControllerCamera{
func backFromCamera()
}
class Camera: UIViewController{
var delegate: communicationControllerCamera
init(){
self.delegate.backFromCamera()
}
}
class SceneBuilder: UIViewController, communicationControllerCamera{
func backFromCamera(){ // Never called
println("YEAHH")
}
}
Run Code Online (Sandbox Code Playgroud)
它没有被调用的backFromCamera方法.我做错了什么?
我正试图在一个独特的output.mov中合并一些视频.导出的文件无法播放,我现在不知道为什么.有人能帮我吗?
func exportVideo2(path:String, outputPath:String, nMovie:Int) -> Bool{
var composition = AVMutableComposition()
let track:AVMutableCompositionTrack = composition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: CMPersistentTrackID())
var insertTime = kCMTimeZero
var movie = movieOfProject(path)
if movie.count == nMovie{
for (index,mov) in enumerate(movie){
let moviePath = path.stringByAppendingPathComponent(mov)
// moviePath = path to the .mov file
println(moviePath)
let moviePathUrl = NSURL(fileURLWithPath: moviePath)
let sourceAsset = AVURLAsset(URL: moviePathUrl, options: nil)
println(sourceAsset)
let tracks = sourceAsset.tracksWithMediaType(AVMediaTypeVideo)
println(sourceAsset.playable) // print true
println(sourceAsset.exportable) // print true
println(sourceAsset.readable) // print true
if tracks.count > 0{
let …Run Code Online (Sandbox Code Playgroud) 我在一个客观的c类中有这个协议:
@protocol YTManagerDelegate <NSObject>
@required
- (void)uploadProgressPercentage:(int)percentage;
@end
...
Run Code Online (Sandbox Code Playgroud)
和一个与之相关的快速课程:
class YTShare: UIViewController, YTManagerDelegate{
func uploadProgressPercentage(percentage:Int?){
println(percentage)
}
...
Run Code Online (Sandbox Code Playgroud)
我收到错误:类型YTShare不符合协议YTShareDelegate,我可能错误地写了swift函数,所以obj类没有找到它.我怎么写得正确?
我有一个动态框架 X,这个框架使用手动导入的 Firebase SDK(静态库)。
我还有一个普通的 iOS 项目 Y,其中包含框架 X 作为嵌入式二进制文件。X 导入到 Y 项目的 AppDelegate.swift 中。
import X
Run Code Online (Sandbox Code Playgroud)
在这里我收到此错误:“缺少必需的模块 Firebase”
这怎么可能?有一些特定的程序可以在框架中设置 Firebase 静态库吗?
我正在尝试使用 AcceleratevImageHistogramCalculation_ARGBFFFF函数计算图像的直方图,但我得到了一个vImage_Error类型kvImageNullPointerArgument(错误代码是-21772)。
这是完全相同的问题,但我在 Swift 中工作:使用 vImageHistogramCalculation 计算图像的直方图
// Get CGImage from UIImage
var image:UIImage = UIImage(named: "happiness1")!
var img:CGImageRef = image.CGImage
// Create vImage_Buffer with data from CGImageRef
var inProvider:CGDataProviderRef = CGImageGetDataProvider(img)
var inBitmapData:CFDataRef = CGDataProviderCopyData(inProvider)
// The next three lines set up the inBuffer object
var height:vImagePixelCount = CGImageGetHeight(img)
var width:vImagePixelCount = CGImageGetWidth(img)
var rowBytes:UInt = CGImageGetBytesPerRow(img)
var data:UnsafePointer<Void> = UnsafePointer<Void>(CFDataGetBytePtr(inBitmapData))
// Setup inBuffer
var inBuffer = vImage_Buffer(data: &data, height: …Run Code Online (Sandbox Code Playgroud) let numbers = [1, 6, 3, 9, 4, 6]
let min = minElement(numbers) // 1
let position = find(array, min)!
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来找到数组中次要元素的位置?循环搜索,在这种情况下最快.
min = Int.max
for (index,value) in enumerate(array){
if value < min{
min = value
position = index
}
}
Run Code Online (Sandbox Code Playgroud) 我发现在Swift中使用带有复合主键的Realm这个很棒的解决方案:https://github.com/realm/realm-cocoa/issues/1192
public final class Card: Object {
public dynamic var id = 0 {
didSet {
compoundKey = compoundKeyValue()
}
}
public dynamic var type = "" {
didSet {
compoundKey = compoundKeyValue()
}
}
public dynamic lazy var compoundKey: String = self.compoundKeyValue()
public override static func primaryKey() -> String? {
return "compoundKey"
}
private func compoundKeyValue() -> String {
return "\(id)-\(type)"
}
}
Run Code Online (Sandbox Code Playgroud)
但我发现Realm不支持延迟属性,在我的情况下我收到此错误:
exception NSException*name:"RLMException" - reason:"在Realm Swift对象类上不允许使用惰性托管属性'compoundKey'.要么将属性添加到忽略的属性列表中,要么将其设置为非惰性." 0x00007f8a05108060
是否仍然可以使用没有懒惰属性的复合键?
很高兴听到我正在做的视频应用程序的一些新iPhone的视频稳定性,但是你如何在一个功能强大的设备上实现它的录制会话呢?查看API文档,只有一种方法可以检查它是否受支持,在iOS 8中不推荐开启/关闭它的方法.它是自动的还是什么?
我们在连接 SHA1 生产指纹时遇到了 Firebase 错误。
应用 X 已在 Google Play 商店中发布,但未连接到 Firebase。我们已经使用旧的签名证书 (jks) 更新了应用程序,并且我们已经将应用程序与一个全新的 Firebase 帐户连接起来。
我们成功地将 Android 应用程序添加到新项目中,但是当我们尝试为生产 Firebase 添加 SHA1 指纹时,返回此错误
{
"error": {
"code": 403,
"message": "clientauthconfig.clients.get not allowed: \ncom.google.identity.boq.appidentity.authorization.PermissionDeniedException",
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.internal.firebase.v1.ErrorCode"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
一些想法?
我需要UIPageControl使用自定义图像而不是普通点来实现.所以我创建了一个自定义类并通过故事板连接它.从ios7开始,UIPageControl的子视图包含UIView而不是UIImageView.结果UIView(UIIpageControl子视图)的子视图不包含任何子视图,因此我收到错误:
致命错误:在展开Optional值时意外发现nil.
我可能错在哪里?
class WhitePageControl:UIPageControl{
let activeImage = UIImage(named: "dot_white")
let inactiveImage = UIImage(named: "dot_white_e")
override init(frame: CGRect){
super.init(frame: frame)
}
required init(coder aDecoder: NSCoder){
super.init(coder: aDecoder)
}
func updateDots(){
println(self.subviews.count) // 3
println(self.numberOfPages) // 3
for var index = 0; index < self.subviews.count; index++ {
println(index)
var dot:UIImageView!
var dotView:UIView = self.subviews[index] as UIView
println("1")
for subview in dotView.subviews{ // NIL HERE
println("2")
if subview.isKindOfClass(UIImageView){
println("3")
dot = …Run Code Online (Sandbox Code Playgroud) Firebase可能会自动取消Firebase功能部署吗?
我们只需运行部署:
firebase deploy --only functions
Run Code Online (Sandbox Code Playgroud)
并且我们发现许多数据库处理函数在几周后停止调用.此功能在Firebase控制台中列出,但调用次数为0.
通过另一次部署,该函数返回正常工作,并响应数据库更改.
swift ×9
ios ×5
firebase ×3
avfoundation ×2
objective-c ×2
android ×1
arrays ×1
compound-key ×1
delegates ×1
histogram ×1
null ×1
protocols ×1
realm ×1
vimage ×1