Card not responding

Look the screen shot attached
one card is not responding after first click ?

all other works good !

The App should be operating in Landscape mode so the first thing you need to do is change the project settings to force the device to only operate in Landscape mode. This won’t have any effect on the problem you are encountering but it should look and operate a little better.

You do that by selecting the Project at the root level (as per the attached image) and then the Match App under TARGETS. Ensure that the only Device Orientation settings selected are Landscape Left and Landscape Right.

Without seeing your code in detail for CardCollectionViewCell it’s a bit difficult to tell what the problem is.

hi
the app is operating in landscape mode only ! but ididnt understand why its coming on portrait on screen ?

In my iPhonee 11 pro is coming landscape mode only !

and also now I have a new problem

now when I click on the card it doesn’t flip over ! I was just following up the lesson no 27 in last minute the just ran the test ?
then once I click on card nothing happens

Please copy and paste your CardCollectionViewCell code in a reply so that we can help you.

import UIKit

class CardCollectionViewCell: UICollectionViewCell {

@IBOutlet weak var frontImageView: UIImageView!

@IBOutlet weak var backImageView: UIImageView!

var card:Card?

func configureCell (card:Card){
    
    //Keep track of the card this cell represents
    self.card = card
    
    //Set the front Image view to the image that represents the card
    frontImageView.image = UIImage(named: card.imageName)
    
    // Reset the state of the cell by checking the flipped status of the card and then showing  the front or the back imageview accordingly
    
    if card.isMatched == true {
        
        backImageView.alpha = 0
        frontImageView.alpha = 0
        return
    }
    
    else {
        
        backImageView.alpha = 1
        frontImageView.alpha = 1
        
    }
    if card.isFlipped == true {
        // Show the front image view
        flipUp(speed: 0)
    }
    
    else {
        
        
        // Show the back image view
        flipDown(speed:0, delay:0)
        
    }
    
    
    
    
}

func flipUp(speed:TimeInterval = 0.3) {
    
    UIView.transition(from: backImageView, to: frontImageView, duration: speed, options: [.showHideTransitionViews ,. transitionFlipFromLeft], completion:nil)
    
    //set the status of the card
    
    card?.isFlipped = true
    
    
}
func flipDown (speed:TimeInterval = 0.3, delay:TimeInterval = 0.5) {
    
    DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
        
        UIView.transition(from: self.frontImageView, to: self.backImageView, duration: speed, options: [.showHideTransitionViews ,. transitionFlipFromLeft], completion:nil)
        
}
    
    
    //Set the status of the card
    
    card?.isFlipped = false
}

func remove () {
    
    // Make the image views invisible
    backImageView.alpha = 0
    
    UIView.animate(withDuration: 0.3, delay: 0.5, options:.curveEaseOut, animations:{
        
        self.frontImageView.alpha = 0
    }, completion: nil)
}

}

@usmancp08

Hi Usman,

I’m guessing that at this point in the App build you are only part of the way through the lessons. My code for the same project is different because I have finished the project so trying to figure out what should be happening at the point that you are at is not simple.

Would you mind compressing your project into a zip file and posting it to DropBox and provide a link here so I can take a look at the project for you?

pls find the drop box link

Hi Usman,

There were a few issues.

You had the two functions checkForGameEnd() and showAlert() inside the function checkForMatch().

There was an additional collectionView method “willDisplay” added that was not required and the code that was in that should have been in cellForRowAt.

With those corrections now made the App works a little better though there are still a couple of logic issues to be sorted out with cards flipping randomly that should not.

Here’s a link to your updated project.

1 Like

I will try to re-run the code , this game is bit hard to catch for me as I am doing between the work and extremely busy time ! Still Want to Build my own app so that I Believe in next lesson I could do better !

It takes a long time to become good at coding so just keep going and you will get there.

1 Like

any howe I would like to join the iOS Training That Pays Off /CWPS PRO , Bothe are same right ?

My understanding is that the “IOS Training that Actually pays off” is CWC Plus which gives you access to all of the courses Chris Ching has on offer.

That covers Fundamentals, Database and Design.

Just so that there is no confusion my name is Chris as well but I’m one of the Moderators of this Code Crew community forum. Chris Ching is the owner and founder of CodeWithChris.com

1 Like

good, will join soon :v:t2:

hi

290 dollar is one time pay right for life time access ?

yes, that one is the lifetime access, but you only get the course lifetime updates, and the students forum.

CWC+ is the newer thing, you get every single thing that chris has to offer but nothing is lifetime access. once you cancel your subscription, your access to all the paid stuff ends.

Just so you know, CWC+ has the courses plus ios bento, the exclusive one-day-builds and a bunch of other cool stuff.

is that possible to know that course content ?
just to know !

In a way.

if you want the lifetime access thing, you visit https://codewithchris.com/beginnercourse/ to learn about each module.