msniff16 / mailbox-app

Replica of mailbox app for iOS
1 stars 1 forks source link

iOS Bootcamp [Project 3] #1

Open msniff16 opened 9 years ago

msniff16 commented 9 years ago

Please review /cc @codepath

drnick23 commented 9 years ago

The goal of this assignment is to handle different gestures along with animating various view properties such as position, size, rotation, and alpha, so that you could implement common effects such as swiping a row in a table, revealing or hiding a tray, or dragging and dropping items.

You've almost got the requirements but need a little refinement on the gestures. I would recommend using the translation property of the gesture to help you, rather than working from the location.

e.g. use: let translation = panGestureRecognizer.translationInView(view)

You also need to include if statements for each gesture state, otherwise you will get problems. For instance, you should only test for velocity in the end state of a gesture.

Try something more along the lines of:

if sender.state == UIPanGestureRecognizerState.Begin {

} else if sender.state == UIPanGestureRecognizerState.Changed {

// test on translation for panning here, e.g. if translation.x > 60 { // change color }

} else if sender.state == UIPanGestureRecognizerState.Ended {

// do your velocity tests for swipes here... }

Try the above and resubmit or ask questions if you need to.

You gave yourself some extra challenge by using the container view controller, and passing functions back to parent view controllers. While it's possible to pass the child view controller it's parent, and call functions directly on that (as you did with InboxViewController, one way to separate communication between two view controllers is through the explicit use of delegates and protocols. You got the right idea, and a further refinement to your code could be to implement the delegate/protocol pattern with some minor adjustments like this:

protocol MessageContainerDelegate { // this is where your message container defines the things it needs it's parent view controller to handle func setRescheduleAlpha(amount:CGFloat) }

// add the MessageContainerDelegate protocol to the inbox view controller class InboxViewController: UIViewController, MessageContainerDelegate, UIScrollViewDelegate, UIGestureRecognizerDelegate {

func setRescheduleAlpha(amount:CGFloat) { // implement what you intend to do when the message container calls this }

}

I'll briefly cover how to use the delegate/protocol pattern in the next lecture.

msniff16 commented 9 years ago

Yeah - i was just trying to do this the simple way thru use of directly accessing the parent's properties haha. Was comfortable with delegate pattern in objective C, but just was lazy and took the easy route instead of implementing the proper way in swift :stuck_out_tongue: