Tag: 返回

返回函数内部无效

我正在尝试创build一个自定义类来点击图片。 在里面,我想创build一个返回一个UIImage的clickPicture函数。 但是, captureStillImageAsynchronously是一个void 。 我怎样才能返回从我收到的图像? 谢谢。 func clickPicture() -> UIImage? { if let videoConnection = stillImageOutput?.connection(withMediaType: AVMediaTypeVideo) { videoConnection.videoOrientation = .portrait stillImageOutput?.captureStillImageAsynchronously(from: videoConnection, completionHandler: { (sampleBuffer, error) -> Void in if sampleBuffer != nil { let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer) let dataProvider = CGDataProvider(data: imageData!) let cgImageRef = CGImage(jpegDataProviderSource: dataProvider!, decode: nil, shouldInterpolate: true, intent: […]

iOS中的UITextField和键盘pipe理问题

(我目前正在瞄准iOS 2.0。) 我有一个类的子类UITextField和实现UITextFieldDelegate协议。 起初,我并没有把class级设置成自己的代表,当我在现场点击时,键盘自动popup。 到现在为止还挺好。 我用UIReturnKeyDone发送setReturnKeyType:消息,所以它改变了右下angular的button来说完成。 问题是,当我点击完成或按下[返回],什么都没有发生 – 键盘不会消失。 我尝试添加自己作为结束编辑通知的观察者,但是当完成点击时它永远不会被调用; 从谷歌search,似乎只有当领域辞职作为第一响应者被解雇 – 这是我不能发生的一点。 然后,我在这里find答案,build议添加自己作为代表和处理textFieldShouldReturn :. 问题是,一旦我将自己添加为委托,当你点击该字段时,键盘不再popup(而且它没有获得焦点) – 它似乎并不成为第一响应者。 我试着处理textFieldShouldBeginEditing:并返回YES(文档说,应该是默认的,如果不重写),那被调用,但没有任何区别。 在我的无知中,我尝试了[textField becomeFirstResponder],并被堆栈溢出(现在我知道这是响应调用成为第一响应者)。 我现在彻底卡住了! 谁能帮忙? 当用户单击完成或按[返回]时,我只想让键盘消失。

tableView:viewForHeaderInSection:默认值?

我想有一个自定义节头,其余的默认头。 – (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return ???; } 我该如何返回到默认的标题视图?

键盘完成关键行动迅速iOS不工作

我是新的在stackoverflow,我有一个新的swift代码的问题。 我已经定制了“完成”键盘上的返回button,但是当我点击它时,不要降临任何东西…如何隐藏键盘上的键盘? 我已经添加了一个代码(在这个网站上find)用于隐藏键盘,当你点击某个地方,而不是在键盘上,但我不能定制它点击“完成”button…谢谢你!

从分析查询块返回UIImage数组

我不能从这个函数返回[UIImage?]返回。 getDataInBackgroundWithBlock不会让我设置一个返回值,而不是Void in 。 但是,该块会在迭代时添加到iconArray 。 但是一旦在块之外,数组又是空的。 您将在下面的代码中看到数组所在的注释,并且不能正确打印。 调用连接到数据库,所有数据都在stream动。 这只是返回那个挂断的数组。 class callData { func queryImages() -> [UIImage?] { var iconArray: [UIImage?] = [] var query: PFQuery = PFQuery(className: "QuestionMaster") query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]?, error: NSError?) -> Void in for object in objects! { let imageFiles = object["questionImage"] as! PFFile imageFiles.getDataInBackgroundWithBlock({ (imageData: NSData?, error: NSError?) -> […]

完成处理程序和返回值

我想调用一个方法,它将从其完成处理程序返回一个值。 该方法asynchronous执行,我不想在方法的所有主体执行之前返回一个值。 下面是一些错误的代码来说明我想要实现的: // This is the way I want to call the method NSDictionary *account = [_accountModel getCurrentClient]; // This is the faulty method that I want to fix – (NSDictionary *)getCurrentClient { __block NSDictionary *currentClient = nil; NXOAuth2Account *currentAccount = [[[NXOAuth2AccountStore sharedStore] accounts] lastObject]; [NXOAuth2Request performMethod:@"GET" onResource:[NSURL URLWithString:[NSString stringWithFormat:@"%@/clients/%@", kCatapultHost, currentAccount.userData[@"account_name"]]] usingParameters:nil withAccount:currentAccount […]