cs193p – Project #5 Assignment #5 Step #3 – The Bricks

Please note, this blog entry is from a previous course. You might want to check out the current one.

A new structure provides two sets of information – the view of the brick and its relative frame information (without information about the current device information). Store this structure for each brick in a dictionary:

    var bricks = [Int:Brick]()
    
    struct Brick {
        var relativeFrame: CGRect
        var view: UIView
    }

Continue reading “cs193p – Project #5 Assignment #5 Step #3 – The Bricks”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #5 Assignment #5 Step #2 – The Paddle

Please note, this blog entry is from a previous course. You might want to check out the current one.

Create the paddle lazily. Place it outside (just a little bit) of the game view – which perhaps a bad way to know if it has been created recently. … and make it nice and colorful, with rounded corners etc …

    struct Constants {
        static let PaddleSize = CGSize(width: 80.0, height: 20.0)
        static let PaddleCornerRadius: CGFloat = 5.0
        static let PaddleColor = UIColor.greenColor()
    }

    lazy var paddle: UIView = {
        let paddle = UIView(frame: CGRect(origin: CGPoint(x: -1, y: -1), size: Constants.PaddleSize))
        paddle.backgroundColor = Constants.PaddleColor
        paddle.layer.cornerRadius = Constants.PaddleCornerRadius
        paddle.layer.borderColor = UIColor.blackColor().CGColor
        paddle.layer.borderWidth = 2.0
        paddle.layer.shadowOffset = CGSize(width: 2.0, height: 2.0)
        paddle.layer.shadowOpacity = 0.5
        
        self.gameView.addSubview(paddle)
        
        return paddle
    }()

Continue reading “cs193p – Project #5 Assignment #5 Step #2 – The Paddle”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #5 Assignment #5 Step #1 – The Ball

Please note, this blog entry is from a previous course. You might want to check out the current one.

Task #1

Create a straightforward Breakout game using Dynamic Animator. See the image in the Screen Shots section below to get a general idea of the game, but your UI should not look exactly like the Screen Shot. Creativity is encouraged and will be rewarded.

Hint #1

This assignment is intentionally vague about the feature set of your game to make room for you to show us some creativity. …

Continue reading “cs193p – Project #5 Assignment #5 Step #1 – The Ball”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Lecture #13 Application Lifecycle and Core Motion

Please note, this blog entry is from a previous course. You might want to check out the current one.

NSNotification

Notifications provide a way to react to asynchronous events. e.g.:

NSNotificationCenter.defaultCenter()

func addObserverForName(String, // name of the "radio station"
    object: AnyObject?, // broadcaster (or nil for "anyone")
    queue: NSOperationQueue?) // queue to execute the closure on 
    { (notification: NSNotification) -> Void in
        let info: [NSObject:AnyObject]? = notification.userInfo // notification-specific information
}

Continue reading “cs193p – Lecture #13 Application Lifecycle and Core Motion”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Extra Task #6

Please note, this blog entry is from a previous course. You might want to check out the current one.

Add some UI which displays a new view controller showing a UICollectionView of the first image (or all the images if you want) in all the Tweets that match the search. When a user clicks on an image in this UICollectionView, segue to showing them the Tweet.


Let’s start with the storyboard:

  • Add a collection view controller.
  • Add a segue from the tweet table view controller to the new controller (note: from the controller itself not from one of its elements or table cells) and name the segue.
  • Add a button to the right side of the navigation bar and link it to the unwind method from extra task #3
  • Add a reuse identifier for the collection view cell.
  • Add an image view to the cell (including autolayout constraints).
  • Add an activity indicator on top (including constraints)
  • Finally add a segue from the cell back to the tweets table view controller and name it.

Continue reading “cs193p – Project #4 Assignment #4 Extra Task #6”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Extra Task #5

Please note, this blog entry is from a previous course. You might want to check out the current one.

Make the “most recent searches” table be editable (i.e. let the user swipe left to delete the ones they don’t like).

We need a new method for our model/data source to be able to delete an entry from the user defaults:

    func removeAtIndex(index: Int) {
        var currentSearches = values
        currentSearches.removeAtIndex(index)
        values = currentSearches
    }

… and use it before removing the line from the table:

    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
            RecentSearches().removeAtIndex(indexPath.row)
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
        }
    }

The complete code for extra task #5 is available on GitHub.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Extra Task #4

Please note, this blog entry is from a previous course. You might want to check out the current one.

Instead of opening urls in Safari, display them in your application by segueing to a controller with a UIWebView. You’ll have to provide at least a little bit of “browser control” UI to go along with it (e.g. a “back button”).

Add a new view controller to the storyboard. Add a egue from the mentions table view controller to the new controller (be careful, not from a cell, but from the controller itself!). Add a web view, an activity indicator and a back button (don’t forget constraints for autolayout):

cs193p - Project #4 Assignment #4 Extra Task #4 - web view controller
cs193p – Project #4 Assignment #4 Extra Task #4 – web view controller

Continue reading “cs193p – Project #4 Assignment #4 Extra Task #4”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail