Segue not passing UIImage - ios

I am trying to segue an array of images from a UICollectionViewController to a UITableViewController with static cells. The setup is that when a user presses a cell in the collection view controller, the UIImage in that cell segues to the UIImageView in the table view controller.
The problem is that the image is not appearing in the UITableViewController's UIImageView.
I think that the UIImage is not being passed to the UIImageView in the UITableViewController.
Here is my relevant UICollectionViewController code:
import UIKit
private let reuseIdentifier = "Cell"
class AddImageCollectionViewController: UICollectionViewController {
var mainImages = ["cup", "transport", "beach", "weather", "gear", "money", "technology-1", "web", "people", "nature", "draw", "technology", "screen", "shop", "arrow"]
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: UICollectionViewDataSource
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of items
return mainImages.count
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let screenSize = UIScreen.mainScreen().bounds
let screenWidth = screenSize.width / 3
let screenHeight = screenWidth
let size = CGSize(width: screenWidth, height: screenHeight)
return size
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! AddImageCollectionViewCell
// Configure the cell
cell.mainImageView.image = UIImage(named: mainImages[indexPath.row])
return cell
}
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
collectionView?.reloadData()
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "nextStep" {
if let indexPaths = collectionView?.indexPathsForSelectedItems() {
let destinationViewController = segue.destinationViewController as! AddTableViewController
//let photoViewController = destinationViewController.viewControllers[0] as! PhotoViewController
destinationViewController.imageName = mainImages[indexPaths[0].row]
}
}
}
}
Here is my relevant UITableViewController code:
import UIKit
import CoreData
class AddTableViewController: UITableViewController {
// MARK: - Table view data source
#IBOutlet var photoImageView:UIImageView!
var content:Agenda!
var imageName:String = ""
override func viewDidLoad() {
super.viewDidLoad()
photoImageView.image = UIImage(named: imageName)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
After selecting my cell in the Collection View Controller in the simulator, I get the following error message in the console:
CUICatalog: Invalid asset name supplied:

Related

How to set title in title bar based on which cell is viewed from collectionview cells in xcode ios

I'm making a medals page for an app I have in mind. I have the app set up in such a way that when a medal is clicked, it will open up a page containing a picture of that medal.
If possible, I also wish to add in a description for every medal in their view controllers. How do I achieve that?
Here's a sample of the code I have:
Medal.swift
import UIKit
class Medals: UICollectionViewController
{
// Defining the array
let imageArray = [UIImage(named: "1"), UIImage(named: "2")]
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
//Allows you to populate the cells you've created
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
// cell was from the identifier we named earlier
// we let collectionviewcell handle the connection to UIcollectionviewcell
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! CollectionViewCell
cell.imageView?.image = self.imageArray[indexPath.row]
return cell
}
// How many cells do we want to have inside the collection view? Just count the number of images assigned
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return imageArray.count
}
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
self.performSegueWithIdentifier("showImage", sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showImage"
{
let indexPaths = self.collectionView!.indexPathsForSelectedItems()!
let indexPath = indexPaths[0] as NSIndexPath
let vc = segue.destinationViewController as! MedalDetail
vc.image = self.imageArray[indexPath.row]!
}
}
}
CollectionViewCell.swift
import UIKit
class CollectionViewCell: UICollectionViewCell {
#IBOutlet weak var imageView: UIImageView!
}
medaldetails.swift
import UIKit
class MedalDetail: UIViewController {
#IBOutlet weak var imageView: UIImageView!
#IBOutlet weak var setTitle: UINavigationItem!
var image = UIImage()
var medalTitle = UINavigationItem()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.imageView.image = self.image
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Thanks for you help
edit:
This is how I want the medal page to look like when clicked:
First create array of medalDescriptions in Medals ViewController then in didSelectItemAtIndexPath call performSegue to MedalDetail viewController
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let index = indexPath.row
self.performSegueWithIdentifier("SegueMedalDetail", sender: nil)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "SegueChallenge" {
let medalDetailViewController = segue.destinationViewController as! MedalDetail
medalDetailViewController.medalDescription = medalDescriptions[index]
}
}
In MedalDetail create medalDescription and in the same viewController change navbar title
override func viewDidAppear(animated: Bool) {
self.navigationController?.navigationBarHidden = false
self.navigationItem.title = medalDescription
self.navigationController!.navigationBar.tintColor = UIColor.whiteColor()
let attributes = [
NSForegroundColorAttributeName: UIColor.whiteColor(),
NSFontAttributeName: UIFont(name: "Helvetica", size: 50)!
]
self.navigationController?.navigationBar.titleTextAttributes = attributes
}
For future do not name your controllers or other class with just their names add also ViewController or View at the end. For example, MedalDetailViewController. That would be better to understand and read
Nevermind, I found another way to do it. I instantiated separate view controller for each medal and thus I can have diffwrent properties per view controller.

UiTableView to UiTableView to UiViewcontroller swift

I am new here and to coding and I need some help with a project that I'm currently stuck on.
I have built an app containing UITableView the first displays body areas (Gastro, cardio, respiratory, etc), the second displays more detailed features on the first (in gastro the table will display stomach, small intestine, colon, etc) and then the the UIViewController will have the more detailed info on the stomach etc.
I have this working all ok but one problem has arose. The UIViewController, regardless of which option is selected in the first table, displays the same info, i.e I get results for gastro even after selecting cardio etc.
Below is my code. I hope someone could help with this. I would really appreciate it!
import UIKit
class Chapters: UITableViewController {
var ChaptersArray = [String]()
var SubchaptersArray = [secondTable]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// chapter names
ChaptersArray = ["Gastrointestinal","Cardiovascular","Respiratory","Central Nervous System", "Infections"]
// subcharpter names
SubchaptersArray = [secondTable(SecondTitle: ["Gas1", "Gas2", "Gas3", "Gas4"]),
secondTable(SecondTitle: ["Card1", "Card2", "Card3", "Card4"]),
secondTable(SecondTitle: ["Res1", "Res2", "Res3", "Res4"])]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tableView(tableview: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableview.dequeueReusableCellWithIdentifier("Cell") as UITableViewCell!
cell.textLabel?.text = ChaptersArray[indexPath.row]
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return ChaptersArray.count
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let indexPath: NSIndexPath = self.tableView.indexPathForSelectedRow!
let destViewController = segue.destinationViewController as! Subchapters
var secondTableArrayTwo : secondTable
secondTableArrayTwo = SubchaptersArray[indexPath.row]
destViewController.SubChaptersArray = secondTableArrayTwo.SecondTitle
}
}
import UIKit
class Subchapters: UITableViewController {
var SubChaptersArray = [String]()
var identities = [String]()
var data = [String]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
identities = ["G1","G2","G3","G4"]
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return SubChaptersArray.count
}
override func tableView(tableview: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableview.dequeueReusableCellWithIdentifier("SecondCell") as UITableViewCell!
cell.textLabel?.text = SubChaptersArray[indexPath.row]
return cell
}
// ignore
// override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// let destViewController = segue.destinationViewController as! DrugNotes
// destViewController.FirstString = "drug data: need to seperate out to seperate pages" }
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let vcName = identities[indexPath.row]
let viewcontroller = storyboard?.instantiateViewControllerWithIdentifier(vcName)
self.navigationController?.pushViewController(viewcontroller!, animated: true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

UITableView is not showing up on physical device deployment

I created a UITableView and fed it some data using code.
While running the application on Xcode simulator it works fine but when I deploy it on physical device, the UITableView is not visible.
Image - 1 (Simulator)
Image - 2 (Device)
Below is my Code:
import UIKit
class OTCMedicines: UIViewController, UITableViewDelegate, UITableViewDataSource{
#IBOutlet weak var tableView: UITableView!
struct Med {
var name:String
var detail:String
var imageName:String
var image: UIImage {
get {
return UIImage(named: imageName)!
}
}
}
var data:[Med]=[Med]()
override func viewDidLoad() {
super.viewDidLoad()
print("OTC Loaded")
data.append(Med(name:"Nimprex P",detail:"Fever and Painkiller",imageName:"db"))
data.append(Med(name:"Cozi Plus",detail:"Cold and Fever",imageName:"db"))
data.append(Med(name:"Combiflam",detail:"Headach and Painkiller",imageName:"db"))
data.append(Med(name:"Flexon",detail:"Muscle Painkiller",imageName:"db"))
data.append(Med(name:"Avil",detail:"Antibiotic",imageName:"db"))
data.append(Med(name:"Cetirizine",detail:"Antibiotic and Allergy",imageName:"db"))
data.append(Med(name:"LIV 52",detail:"Lever Problems",imageName:"db"))
data.append(Med(name:"Perinorm",detail:"Stomach-ach and Puke",imageName:"db"))
data.append(Med(name:"Edicone Plus",detail:"Fever and Cold",imageName:"db"))
data.append(Med(name:"L-Hist Mont",detail:"Peanut Allergies",imageName:"db"))
tableView.delegate = self
tableView.dataSource = self
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("MedicineCell") as! OTCMedCell!
let medView = data[indexPath.row]
print("OTC Table Cell Loaded")
cell.medName.text = medView.name
cell.medImage.image = medView.image
cell.medDetail.text = medView.detail
return cell
}
// MARK: UITableViewDelegate Methods
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "OTCMedPush" {
if let destination = segue.destinationViewController as? OTCMedicineDetail {
if let medIndex = tableView.indexPathForSelectedRow?.row {
destination.medicineValue = data[medIndex].name
}
}
}
}
}
Both simulator and iPhone are model 5s, running on iOS 9.2
I believe you need to reload the table after you added all the elements in viewDidLoad.
self.UITableView.reloadData()
Seems you must insert these lines in viewDidLoad:
self.tableView.registerNib(UINib(nibName: "OTCMedCell", bundle:nil), forCellReuseIdentifier: "MedicineCell")
self.tableView.reloadData()
Also, in your cellForRowAtIndexPath modify your line:
let cell = tableView.dequeueReusableCellWithIdentifier("MedicineCell") as! OTCMedCell!
with:
let cellIdentifier : String! = "MedicineCell"
var cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier) as? OTCMedCell!
if cell == nil {
cell = OTCMedCell(style: UITableViewCellStyle.Default, reuseIdentifier: (cellIdentifier))
}

Scale image to fit - iOS

I have a UICollectionView that displays 12 images. The images are not fitting in the cells, they are being cropped, but I want them to fit in the cells without being cropped.
The code that should make the image scale to fit is:
cell.imageView.contentMode = UIViewContentMode.ScaleAspectFit
cell.imageView.image = UIImage(named: name)
Here is my code for the whole viewController class and screenshot:
import UIKit
class DressingRoomViewController:
UIViewController,
UICollectionViewDelegateFlowLayout,
UICollectionViewDataSource {
#IBOutlet weak var collectionView: UICollectionView!
let identifier = "cellIdentifier"
let dataSource = DataSource()
override func viewDidLoad() {
super.viewDidLoad()
collectionView.dataSource = self
}
override func viewDidAppear(animated: Bool) {
// Notes on the equation to get the cell size:
// cells per row = 6
// cell spacing = 10
// collectionView.layout.inset = 20 (10 left, 10 right)
let cellSize = (collectionView.collectionViewLayout
.collectionViewContentSize().width - 20) / 6 - 10
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets( top: 20,
left: 10,
bottom: 10,
right: 10)
layout.itemSize = CGSize(width: cellSize, height: cellSize)
collectionView.collectionViewLayout = layout
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func prepareForSegue( segue: UIStoryboardSegue,
sender: AnyObject?) {
if (segue.identifier == "dressingRoom2MyOutfits") {
let myOutfitsViewController = segue.destinationViewController
as! MyOutfitsViewController
}
}
}
// MARK:- UICollectionViewDataSource Delegate
extension DressingRoomViewController : UICollectionViewDataSource {
func numberOfSectionsInCollectionView(
collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView,
numberOfItemsInSection section: Int) -> Int {
return 12
}
func collectionView(collectionView: UICollectionView,
cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(
identifier,forIndexPath:indexPath) as! FruitCell
let fruits: [Fruit] = dataSource.fruits
let fruit = fruits[indexPath.row]
let name = fruit.name!
cell.imageView.contentMode = UIViewContentMode.ScaleAspectFit
cell.imageView.image = UIImage(named: name)
return cell
}
}
EDIT: Here is the FruitCell class, just in case you were wondering.
class FruitCell: UICollectionViewCell {
#IBOutlet weak var imageView: UIImageView!
}
A UIImageView that has been placed in a UICollectionViewCell from the interface builder, will not have any knowledge of a UICollectionViewFlowLayout that has been initialised programmatically. So the layout.sectionInset that I had set, was making the UICollectionViewCells smaller, and even when the UIImageView created in interface builder was constrained to the margins of the UICollectionViewCell, the UIImageView was not resizing to go smaller.
The solution was to initialise the UIImageView programmatically and set the size to be the size of the cell taking into account the cell spacing.
Here is the code:
import UIKit
class DressingRoomViewController:
UIViewController,
UICollectionViewDelegateFlowLayout,
UICollectionViewDataSource {
#IBOutlet weak var collectionView: UICollectionView!
let identifier = "cellIdentifier"
let dataSource = DataSource()
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
let cellSpacing: CGFloat = 2
let cellsPerRow: CGFloat = 6
override func viewDidLoad() {
super.viewDidLoad()
collectionView.dataSource = self
}
override func viewDidAppear(animated: Bool) {
let cellSize = (collectionView.collectionViewLayout
.collectionViewContentSize().width / cellsPerRow) - (cellSpacing)
layout.itemSize = CGSize(width: cellSize, height: cellSize)
layout.minimumInteritemSpacing = cellSpacing
layout.minimumLineSpacing = cellSpacing
collectionView.collectionViewLayout = layout
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func prepareForSegue( segue: UIStoryboardSegue,
sender: AnyObject?) {
if (segue.identifier == "dressingRoom2MyOutfits") {
let myOutfitsViewController = segue.destinationViewController
as! MyOutfitsViewController
}
}
}
// MARK:- UICollectionViewDataSource Delegate
extension DressingRoomViewController : UICollectionViewDataSource {
func numberOfSectionsInCollectionView(
collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView,
numberOfItemsInSection section: Int) -> Int {
return 12
}
func collectionView(collectionView: UICollectionView,
cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(
identifier,forIndexPath:indexPath) as! FruitCell
let fruits: [Fruit] = dataSource.fruits
let fruit = fruits[indexPath.row]
let name = fruit.name!
var imageView :UIImageView
imageView = UIImageView(frame:CGRectMake( 0,
0,
(collectionView.collectionViewLayout
.collectionViewContentSize().width / cellsPerRow)
- (cellSpacing),
(collectionView.collectionViewLayout
.collectionViewContentSize().width / cellsPerRow)
- (cellSpacing)))
imageView.contentMode = UIViewContentMode.ScaleAspectFit
imageView.image = UIImage(named: name)
imageView.backgroundColor = UIColor.redColor()
cell.addSubview(imageView)
return cell
}
}
EDIT: I was able to crop off the empty space at the bottom of the UICollectionView by creating an outlet for the height constraint ( control + drag height constraint in interface builder onto viewController swift file) calling it heightConstraint, and then at the bottom of viewDidAppear added these two lines of code:
self.heightConstraint.constant = collectionView.contentSize.height
self.view.layoutIfNeeded()
So to show you the result with a white background on the UICollectionView and a red background on the UIImageViews, here is the result (also works on all other device sizes):

UICollectionView to DetailView Swift, using parse

i have a UICollectionview that gets images form Parse.
I'm now trying to push to a detail view then I'm push on a image in the UICollectionView.
Do anybody have any idea on how to do this?
Here is my code:
viewcontroller:
import UIKit
import Parse
class ViewController: UIViewController, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
#IBOutlet var collectionView: UICollectionView?
var imageFilesArray:NSArray = NSArray()
var refreshControl: UIRefreshControl!
// var isAscending = true
override func viewDidLoad() {
super.viewDidLoad()
self.refreshControl = UIRefreshControl()
self.refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
self.refreshControl.addTarget(self, action: Selector("imageRefresh"), forControlEvents: UIControlEvents.ValueChanged)
self.refreshControl.tintColor = UIColor.whiteColor()
self.collectionView?.addSubview(refreshControl)
// Do any additional setup after loading the view, typically from a nib.
//let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
//layout.sectionInset = UIEdgeInsets(top: 20, left: 10, bottom: 20, right: 10)
//layout.itemSize = CGSize(width: 150 , height: 150)
// collectionView = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)
collectionView!.dataSource = self
collectionView!.delegate = self
collectionView!.registerClass(CollectionViewCell.self, forCellWithReuseIdentifier: "imageCell")
collectionView?.alwaysBounceVertical = true
//collectionView!.backgroundColor = UIColor.whiteColor()
self.view.addSubview(collectionView!)
parseQuery()
}
func parseQuery() {
//query
var query = PFQuery(className: "photo")
query.orderByDescending("createdAt")
query.findObjectsInBackgroundWithBlock{
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
self.imageFilesArray = objects
//println(self.imageFilesArray)
}
self.collectionView?.reloadData()
}
}
func imageRefresh() {
parseQuery()
self.refreshControl.endRefreshing()
}
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
println(self.imageFilesArray.count)
return self.imageFilesArray.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("imageCell", forIndexPath: indexPath) as CollectionViewCell
cell.backgroundColor = UIColor.blackColor()
let imageObject = self.imageFilesArray.objectAtIndex(indexPath.row) as PFObject
let imageFile = imageObject.objectForKey("imageFile") as PFFile
imageFile.getDataInBackgroundWithBlock{
(data: NSData!, error: NSError!) -> Void in
if error == nil {
cell.imageView.image = UIImage(data: data)
}
}
return cell
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
collectionviewcell:
import UIKit
class CollectionViewCell: UICollectionViewCell {
#IBOutlet var imageView: UIImageView!
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override init(frame: CGRect) {
super.init(frame: frame)
imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height))
imageView.contentMode = UIViewContentMode.ScaleToFill
contentView.addSubview(imageView)
}
}
Detailviewcontroller:
import UIKit
import Parse
class photoDetailViewController: UIViewController {
#IBOutlet var detailImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
i hope somebody can help on on how to write the code to push to the detail view, and show the same image that was pressed.
--
OlePetter
Update your didSelectItemAtIndexPath method,
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath)
{
var detailsViewController: DetailsViewController = DetailsViewController(nibName:"DetailsViewController",bundle:nil)
self.presentViewController(detailsViewController, animated: true) { () -> Void in
}
}
Note: In place of DetailsViewController write your own Details ViewController's name. and write you own nibName.

Resources