Closed peterwarbo closed 11 years ago
So there are two different classes that make the controller work
KLNoteViewController - Manages the KLControllerCards (animation, coordinates, etc.) KLControllerCard - Displays the content of each card
The implementation you are looking at is within the KLControllerCard and has no concept of where it will be drawn (since it is essentially a uiview that handles its own resizing via transform).
It is the responsibility of the KLNoteViewController to determine at what coordinate the KLControllerCard originates at. For this reason, the ControllerCard calls its parent controller (noteView - of class type KLNoteViewController) to get it's y origin.
The point of confusion probably stems from the fact that the responsibilities are not well defined. KLControllerCard is actually setting its own yCoordinate, but requesting it from the KLNoteViewController. It would be a better solution to have the KLNoteViewController handle the KLControllerCard frames itself.
Hope that helps,
Kieran
On 2013-02-25, at 9:09 AM, Peter Warbo notifications@github.com wrote:
Just curious why you assigning to self before calling super in the init of KLControllerCard?
@implementation KLControllerCard
-(id) initWithNoteViewController: (KLNoteViewController) noteView navigationController:(UINavigationController) navigationController index:(NSInteger) _index {
self.noteViewController = noteView; self.navigationController = navigationController; //Set the instance variables index = _index; originY = [noteView defaultVerticalOriginForControllerCard:self atIndex: index];
— Reply to this email directly or view it on GitHub.
Thanks for clearing up a little of the confusion but I still don't understand why you are assigning to self before calling super? In all the books I've read you should always call the super init to see if you get back a properly initialized object and then you can send messages to self. I just upgraded to Xcode 4.6 and I'm getting compiler warnings because of this.
In the line below what you pasted, I did call super initWithFrame:
if (self = [super initWithFrame: navigationController.view.bounds]) {
Yep you are certainly doing that but before calling super you are doing a couple of other things like self.noteViewController = noteView;
Right, I agree that it should be called after super initWithFrame: and will make the changes after testing a bit
No biggie, I didn't even notice it until upgrading to latest Xcode (4.6) which gave me compiler warnings. So I was just curious why you had implemented it that way :-)
if (self = [super init]) {
self.noteViewController = noteView;
self.navigationController = navigationController;
//Set the instance variables
index = _index;
originY = [noteView defaultVerticalOriginForControllerCard:self
atIndex: index];
[self setFrame: self.navigationController.view.bounds];
No I appreciate you bringing it up! :) Fixed with latest commit
Just curious why you assigning to self before calling super in the init of KLControllerCard?