dimanche 1 mars 2015

adding a custom transition to presentViewController in swift

i have a viewController which has a TableView and a cell with a accessoryType of detailbutton. When pressing that accessoryType i present a semi transparent View with text.


I want this view to appear in a specific way so i created a custom view controller.


However trying to run that viewController in the detailbutton will not work.


parts of my code:



//Defined in the class
let customTransitionManager = TransitionManager()

//in tableView cellForRowAtIndexPath
if (tableView == continent){
let cell:UITableViewCell = UITableViewCell(style:UITableViewCellStyle.Default, reuseIdentifier: "continentSelector")
cell.textLabel?.text = "Continent"
cell.accessoryType = UITableViewCellAccessoryType.DetailButton;
return cell


func tableView(tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath){
println(indexPath)
let detailController = storyboard?.instantiateViewControllerWithIdentifier("detailButtonStoryBoard") as? detailedView
detailController?.modalPresentationStyle = .Custom
detailController?.transitioningDelegate = customTransitionManager;
presentViewController(detailController!, animated: true, completion: nil)
}


Running this code gives me the following error:



fatal error: unexpectedly found nil while unwrapping an Optional value


The following gets highlighted:



-> 0x100209cf0 <function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> ()+44>: brk #0x1



Aucun commentaire:

Enregistrer un commentaire