我正在使用storyboard创建一个包含5个步骤的用户设置帐户.每一步都有一个ViewController:1º)输入名称,联系人等,2º)导入照片,3º)输入等4º)更多输入5º)确认页面,如果用户点击"确认" - >获取所有输入并上传到解析.
我在网上搜索时获得的唯一解决方案是创建一个功能"准备Segue"并传递信息......但对我来说,这没有任何意义:
如果我有1000个viewcontrollers,第一个viewcontroller信息将通过所有1000个viewcontrollers传递?为什么nº1000视图控制器不能获取留下的所有信息?例如:viewcontrollernº50不需要有关viewcontrollernº1的信息......这是一个废话.
有没有其他方法来实现这个?
也许有一个解决方案,因为我正在使用Parse,就像我这样做:
ParseClass ["Name"] = textfield.text
它向Parse发送信息,他们持有它直到我做类似SaveInBackground()的事情.
我正在尝试使用viewcontrollers找到这样的解决方案.每个viewcontroller都发送信息来解析并保存信息,直到Viewcontrollernº5上发生"saveinbackground()".
可能?谢谢
我试图让indexPath.row那个用户点击,然后检查我的数组以从中返回一个字符串,indexPath.row然后通过 preparforSegue 发送字符串......但它不起作用。我认为该程序在didselectRowatIndexPath...之前运行preparForSegue ...我该怎么做?
我的代码:
import UIKit
import Parse
class CategoriaTableViewController: UITableViewController {
var queryArray: [PFObject] = [PFObject]()
var escolha = 5
override func viewDidLoad() {
super.viewDidLoad()
var query = PFQuery(className:"Categorias")
//querycomlocalidade
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
println("Successfully retrieved \(objects!.count) Restaurantes.")
if let _objects = objects as? [PFObject] {
self.queryArray = _objects
self.tableView.reloadData()
}
} else {
println("Error: \(error!) \(error!.userInfo!)")
}
}
}
override func …Run Code Online (Sandbox Code Playgroud) 我从互联网及其工作中添加了此代码.滑动单元格时显示2个按钮,但按钮均为红色.为什么?我该如何改变它们?
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
// 1
var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Aceitar" , handler: { ( action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
// 2
let shareMenu = UIAlertController(title: nil, message: "Confirmar Aceitação", preferredStyle: .ActionSheet)
let twitterAction = UIAlertAction(title: "Twitter", style: UIAlertActionStyle.Default, handler: nil)
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)
shareMenu.addAction(twitterAction)
shareMenu.addAction(cancelAction)
self.presentViewController(shareMenu, animated: true, completion: nil)
})
// 3
var rateAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Recusar" , handler: { (action:UITableViewRowAction!, …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的swift 1.2应用程序转换为2.0.我尝试了一些我在互联网上找到的修复程序,但它不起作用.
错误: Converting to Swift 2.0 - Cannot Subscript a value of type '[CLPlacemark]?'
码:
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
CLGeocoder().reverseGeocodeLocation(manager.location!, completionHandler: {(placemarks, error)->Void in
if (error != nil)
{
print("Error: " + error!.localizedDescription)
return
}
if placemarks!.count > 0
{
let pm = placemarks[0] as! CLPlacemark
self.displayLocationInfo(pm)
}
else
{
print("Error with the data.")
}
})
}
Run Code Online (Sandbox Code Playgroud)