小编Che*_*rif的帖子

MyViewController是否在窗口层次结构中?

有没有办法检查是否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)

uiviewcontroller ios swift

4
推荐指数
1
解决办法
1463
查看次数

Scchaler事件不会在Sencha Touch中触发

我在数据视图中配置了滚动事件,但它们不会触发.其余的可滚动配置都没问题,只是似乎没有考虑听众的配置.任何线索?

{   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)

javascript extjs dom-events sencha-touch sencha-touch-2

3
推荐指数
1
解决办法
2032
查看次数

在iOS上捕获照片时出现随机错误

我正在尝试捕捉图像:

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)

我只是想预料会发生这个错误.我尝试过测试 …

ios avcapture avcapturesession swift

3
推荐指数
1
解决办法
360
查看次数

Mongodb:findOneAndUpdate的数组元素投影不起作用?

我正在使用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)

mongoose mongodb mongodb-query

2
推荐指数
1
解决办法
6991
查看次数

如何在UITableViewCell中刷新UIImage?

这就是我创建单元格的方式:

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内部的事实密切相关!

objective-c uitableview uiimageview ios swift

2
推荐指数
1
解决办法
1150
查看次数

在swift中使用NSDateFormatter时我得到了nil

这是我的代码:

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)

为什么没有?我究竟做错了什么 ?

nsdate nsdateformatter ios swift

1
推荐指数
1
解决办法
2583
查看次数