有没有办法检查是否MyViewController在窗口层次结构中?我想知道我是否可以提供一个UIAlertController:
var alert = UIAlertController(title: "Hello", message: "Just for fun", preferredStyle: UIAlertControllerStyle.Alert)
MyViewController.presentViewController(alert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud) 我在数据视图中配置了滚动事件,但它们不会触发.其余的可滚动配置都没问题,只是似乎没有考虑听众的配置.任何线索?
{ itemId:'names',
xtype:'dataview',
disableSelection:true,
scrollable:{
direction:'vertical',
listeners:{
scroll:function(){
console.log('[scrollable][on scroll]');
},
scrollend:function( scroller, x, y, eOpts ){
console.log('[scrollable][on scrollend]x='+x+', y='+y);
}
}
},
store:{
fields:['name'],
data:[{name:'Cherif'}]
},
itemTpl:'{name}'
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试捕捉图像:
var stillImageOutput = AVCaptureStillImageOutput()
stillImageOutput!.outputSettings = [AVVideoCodecKey: AVVideoCodecJPEG]
[...]
if let videoConnection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo) {
videoConnection.videoOrientation = AVCaptureVideoOrientation.Portrait
println("enabled = \(videoConnection.enabled)") //enabled = true
println("active = \(videoConnection.active)") //active = true
stillImageOutput.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: {
(sampleBuffer, error) in
if error != nil {
println(error)
}
})
}
Run Code Online (Sandbox Code Playgroud)
它大多数时候都很完美!
但有时我在调用时遇到错误captureStillImageAsynchronouslyFromConnection:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation couldn't be completed."
UserInfo=0x14682110 {NSLocalizedDescription=The operation couldn't be completed.,
NSUnderlyingError=0x1676be30 "The operation couldn't be completed.
(OSStatus error -16400.)",
NSLocalizedFailureReason=An unknown error has occured (-16400)}
Run Code Online (Sandbox Code Playgroud)
我只是想预料会发生这个错误.我尝试过测试 …
我正在使用Mongoose,我正在尝试更新数组元素并将其更新回来.这是我的文档结构:
{ name:String,
friends:[
{ name:String,
age:Number
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我执行以下查询时,我得到了结果中的所有朋友,但我只想让25岁的朋友回来:
theCollection.findOneAndUpdate(
{ name : 'cherif',
'friends.name':'kevin'
},
{ $set:{
'friends.$.age':25
}
},
{ friends:
{ $elemMatch:
{ age : 25 }
}
},
function(err,result){
if (!err) {
console.log(result);
}});
Run Code Online (Sandbox Code Playgroud) 这就是我创建单元格的方式:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("FbFriendCell") as! FbFriendCell
cell.initialize()
return cell
}
Run Code Online (Sandbox Code Playgroud)
非常简单.
在initialize()函数中,我下载了一个图像,并将其放在UIImageView中:
let theImageView = UIImageView(image: userPhoto)
theImageView.frame = CGRect(x: 0, y: 0, width: 80, height: 80)
self.addSubview(theImageView)
theImageView.image = userPhoto
println("The image has been set !")
Run Code Online (Sandbox Code Playgroud)
问题是图像仅在此日志消息后几秒出现:
println("The image has been set !")
Run Code Online (Sandbox Code Playgroud)
如何强制图像重新加载?
*阅读这个* =>问题可能与图像在UITableViewCell内部的事实密切相关!
这是我的代码:
println(myStringDate) // 2015-02-26T17:46:34.000Z
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "YYYY-MM-DDTHH:mm:ss.sssZ"
let myDate = dateFormatter.dateFromString(myStringDate)
println(myDate) // nil
Run Code Online (Sandbox Code Playgroud)
为什么没有?我究竟做错了什么 ?
ios ×4
swift ×4
avcapture ×1
dom-events ×1
extjs ×1
javascript ×1
mongodb ×1
mongoose ×1
nsdate ×1
objective-c ×1
sencha-touch ×1
uiimageview ×1
uitableview ×1