Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jnoxx

macrumors 65816
Original poster
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
Hey developers,

Actually, I haven't worked alot with Subclassing.
But I am using this library, Leaves. And I had a question this time too :)
I hope u can figure this out, cuz at iphonedevsdk they are not answering at all..

So, I have this class called leavesview.h
My PDFViewController subclasses this like this -->

Code:
@interface PDFExampleViewController : LeavesViewController

Inside that view, I call a popover like this -->

Code:
- (IBAction) showTOC:(id)sender {
	NSLog(@"showTOC called");
	//IndexViewController *indexViewController = [[IndexViewController alloc] init];
	if (![popoverController isPopoverVisible]){
		myPopOver = [[MyPopOverView alloc] initWithNibName:@"MyPopOverView" bundle:nil];
		popoverController = [[UIPopoverController alloc] initWithContentViewController:myPopOver];
		[popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
	} else{
		[popoverController dismissPopoverAnimated:YES];
	}
}

Which shows from the UIButton ^_-

I load some XML shizzle and stuff in there and load to the directory.

Then inside that popoverview, (UITableView). i have this method -->

Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	//int pageNumber = 3;
	NSUInteger pageNumber = 3;
	[leavesView setCurrentPageIndex:pageNumber-1];
	
	NSLog(@"didSelect fired");
}

So, that gets triggered, but never actually changes it.
but if I do this in my PDFViewController in the viewDidLoad or whatever.
It get's called. so my question was, how is the design pattern in this matter.

the currentPageIndex code goes like this -->

Code:
- (void) setCurrentPageIndex:(NSUInteger)aCurrentPageIndex {
    currentPageIndex = aCurrentPageIndex;
	if (self.mode == LeavesViewModeFacingPages && aCurrentPageIndex % 2 != 0) {
        currentPageIndex = aCurrentPageIndex + 1;
    }
	
	[CATransaction begin];
	[CATransaction setValue:(id)kCFBooleanTrue
					 forKey:kCATransactionDisableActions];
	
	[self getImages];
	
	self.leafEdge = 1.0;
	
	[CATransaction commit];
}

I know it's hard, and I think it's a mather of design pattern errors.
I first' discovered the leavesView in my didSelectRowAtIndex was nil, so i Init that in the viewDidLoad, so it doesn't return nil, so it references to there, but can't figure out why it isn't calling the function (decently).

Any idea's, let me know ^_-

Greets. Noxx
 
So, I have this class called leavesview.h
My PDFViewController subclasses this like this -->

Code:
@interface PDFExampleViewController : LeavesViewController
"leavesview.h" sounds more like the name of the implementation file for a class rather than a class name. Based on that code sample, it looks like LeavesViewController is the name of the class. Remember that in programming and when trying to get help with programming, accuracy is important.
 
Hai Dejoy.

Thanks for actually responding (*weee*).

If u look at my PDFViewController, u see that it also does this -->

Code:
@interface PDFExampleViewController : LeavesViewController <UIAlertViewDelegate, UIWebViewDelegate, UIPopoverControllerDelegate>

Right?

And that works, when for example I put in the viewDidLoad this -->

Code:
[leavesView setCurrentPageIndex:2];

That works fine. and changes the page, etc.

Or when I put a notification center, put that code above this line in a seperate method, call the method via the didselect in the MyPopOverView.
That works too.
but it Subclasses both via the LeavesViewController.

Inside that LeavesViewController u have this -->

Code:
#import <UIKit/UIKit.h>
#import "LeavesView.h"

@interface LeavesViewController : UIViewController <LeavesViewDataSource, LeavesViewDelegate> {
	LeavesView *leavesView;
}

That's it.
So the reference should be made..
First I thought it was the super init method in the PDFViewController, cuz the leavesView was Nil inside the mypopoverview, but another init there doesn't get called.
In the PDFViewController -->

Code:
- (id)initWithPdf: (NSString*) pdfString {
    if (self = [super init]) {
	//random methods calling with initting
    }
    return self;
}

and in my MyPopOverView i had another init method.
But that didn't really work out, so I load this in my MyPopOver

Code:
leavesView = [[LeavesView alloc] initWithFrame:CGRectZero];
	leavesView.mode = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? LeavesViewModeSinglePage : LeavesViewModeFacingPages;

second line is for displaying pages so nvm that.
But still, I have no freaking clue what's the problem ^_-
I know it's alot of stuff im posting, but thanks for helping out ^_- on iphonedevsdk after 2 weeks no answer.


PS: about ur post, i reread it, and yea, I said it wrong. I said leavesView.h is my file. and that's correct, that does exist, but in the PDFExampleViewController.
there u get the reference (like i said above in this post).
Hope I made myself clear, otherwise, please ask away x)
Would like to see this revolved *batman tune*
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.