I am trying to use Leaves sample code from GitHub to display pdf file when UIButton is pressed but when executing the project it is giving error
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: [LeavesCache setDataSource:]: unrecognized selector sent to instance
Added Exception breakpoint and found that problem is at this line
From LeavesView.m
pageCache = [[LeavesCache alloc] initWithPageSize:self.bounds.size];
- (void) initialize {
backgroundRendering = NO;
pageCache = [[LeavesCache alloc] initWithPageSize:self.bounds.size];
}
From LeavesCache.m
- (id) initWithPageSize:(CGSize)aPageSize
{
if (self = [super init]) {
pageSize = aPageSize;
pageCache = [[NSMutableDictionary alloc] init];
}
return self;
}
From LeavesView.m
- (void) setDataSource:(id<LeavesViewDataSource>)value {
pageCache.dataSource = value;
}
Difference is that Leaves project is using Tableviewcontroller but i m using collection view controller with the storyboard segue. In detailviewcontroller have a uibutton which displays pdf file when it is pressed. But when pressing that uibutton it is giving error.
Thanks for help.
If you don't have a dataSource for your collection view controller, then you don't need to call it at all. All a dataSource does is tell your class where to look for the data. Your error is that there is no dataSource property in LeavesCache, and you're trying to set one.
Related
I want to push some information to a UITableView so i have to get the location of that View.
and this is the code inside the AppDelegate :
player = [[player1Data alloc] init];
player.name = #"Dave Brubeck";
player.game = #"Texas Hold’em Poker";
player.rating = 2;
[playersArray addObject:player];
// to get the player1ViewController
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
UITabBarController *tabBarController = [[navigationController viewControllers] objectAtIndex:0];
player1ViewController *playersViewController = [[tabBarController viewControllers] objectAtIndex:0];
playersViewController.playersArray = playersArray;
return YES;
the error was appearing at :
player1ViewController *playersViewController = [[tabBarController viewControllers] objectAtIndex:0];
then the xcode shows that : Thread 1: signal SIGABRT
the console shows :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController viewControllers]: unrecognized selector sent to instance 0x687a880'
here is my storyboard layout, i'm not sure if is it the right arrangement.
Navigation Controller→View Controller(with a button)→Tab Bar Controller→Table View(where i want to show the players info.)
So sorry my English is not very well, hoping u guys could understand what i'm talkin about.
THX!!
The initialization part of UITabBarController is the problem.Assigning a viewconroller from navigationcontroller stack to UITabBarController??
Prepare an array of VC that you need to show in UITabBarController and load it to the viewcontrollers property of UITabBarController
I am getting this error, while I am trying to load another view
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-
[__NSCFType new1:]: unrecognized selector sent to instance 0x5c27950'
Here new1 is a button, which when pressed loads a view.
And here is the code inside the new1
-(IBAction) new1:(id) sender
{
viewController = [[iTViewController alloc] initWithNibName:#"iTViewController" bundle:[NSBundle mainBundle]];
[self.view addSubview:viewController.view];
}
Note: When I launch the App from fresh and press the new1 button, it works flawlessly, but when I press other button which loads other view and when I return back to this view and press new1, then it crashes
The error * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [__NSCFType new1:]: unrecognized selector sent to instance 0x5c27950' may not be coming from inside the - (IBAction)new1:(id)sender method. What that error is saying is that you are trying to call a non-existent method on whatever object is at the address 0x5c27950. Here are a few possible solutions:
Set NSZombieEnabled, malloc stack logging, and guard malloc in the debugger. Then, when your App crashes, type this in the gdb comsole:
(gdb) info malloc-history 0x5c27950
Replace 0x5c27950 with the address of the object that the stack trace says caused the crash,and it will give you a much more useful stack trace and it should highlight the exact line that is causing the problem.
Check out this article for more info on NSZombieEnabled.
This one for MallocStackLogging info
More info on guard malloc here
Also, have you tried pushing the view controller (assuming your using a navigation controller):
- (IBAction)new1:(id)sender {
iTViewController *viewController = [[iTViewController alloc] initWithNibName:#"iTViewController" bundle:nil];
[self.navigationController pushViewController:viewController animated:YES];
[viewController release];
}
Or, if you are not using a nav controller, you can present it modally:
- (IBAction)new1:(id)sender {
iTViewController *viewController = [[iTViewController alloc] initWithNibName:#"iTViewController" bundle:nil];
[self presentModalViewController:viewController animated:YES];
[viewController release];
}
Another possibility is that you are calling [self new1:someButton]; but the method is not declared in your header file like so:
#interface MyViewController: UIViewController {
........
}
- (IBAction)new1:(id)sender;
#end
I have an app where I have a TTTableView Controller inside a Navigation Controller that is Insider a TabBar.
I want it so that if a user selects an item it will push another TTTableView with the items under that category.
The code I have is
-(void)didSelectObject:(id)object atIndexPath:(NSIndexPath *)indexPath {
if ([object isKindOfClass:[TTTableMoreButton class]]) {
[super didSelectObject:object atIndexPath:indexPath];
} else {
CategoryViewController *viewController = [[CategoryViewController alloc] initWithNibName:#"CategoryViewController" bundle:nil];
[self.navigationController pushViewController:viewController animated:YES];
[viewController release];
}
}
The CategoryViewController is setup as
#interface CategoryViewController : TTTableViewController
and the CategoryViewController.xib file has the datasource & delegate set to the files owner and the view set to the tableview and the tableview class is set to TTTableView.
When I run it I get the following error when selecting a row
2011-10-17 16:18:23.819 Biz Insider[34067:f803] -[CategoryViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x6c93d30
2011-10-17 16:18:23.820 Biz Insider[34067:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CategoryViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x6c93d30'
*** First throw call stack:
(0x1893052 0x157ed0a 0x1894ced 0x17f9f00 0x17f9ce2 0xb4cf2b 0xb4f722 0x9ff7c7 0x9ff2c1 0x9b61e 0xa0228c 0xa06783 0x9bb48 0x9b1301 0x1894e72 0x89192d 0x89b827 0x821fa7 0x823ea6 0x823580 0x18679ce 0x17fe670 0x17ca4f6 0x17c9db4 0x17c9ccb 0x1f88879 0x1f8893e 0x972a9b 0x273d 0x26b5)
terminate called throwing an exceptionCurrent language: auto; currently objective-c
If I try and push another view (i have one with a webview on it) then it works fine, or if I go into interface builder and link the File Owner's "tableView" to the TTTableView object it will work fine and push the controller except the "Pull down to refresh" function wont work so I am assuming that the deletage isn't correct when doing it that way.
Any help would be greatly appreciated.
EDIT:
I have a feeling that it has something to do with the following
-(id<UITableViewDelegate>)createDelegate {
return [[[TTTableViewDragRefreshDelegate alloc] initWithController:self] autorelease];
}
This sets the delegate to TTTableViewDragRefreshDelegate which implements the numberOfRowsInSection and all that junk. Is there another way to do this?
Cheers,
Dean
The log says that in your custom class CategoryViewController method tableView:numberOfRowsInSection: is not implemented and so it couldn't call it.
Check it and check types of its parameters.
Well this is an odd one, but I changed it from
CategoryViewController *viewController = [[CategoryViewController alloc] initWithNibName:#"CategoryViewController" bundle:nil];
to
CategoryViewController *viewController = [[CategoryViewController alloc] init];
and it magically works now...dont ask me how or why.
There must have been something in the NIB that was messing it up, but I dont know how the whole layout is working now with no NIB.
I'm using this code to show a popover from the toolbar of the detail view of a split view controller.
- (IBAction)showBookmarksMenu:(id)sender
{
BookmarksViewController* content = [[BookmarksViewController alloc] init];//UITableViewController
UIPopoverController* aPopover = [[UIPopoverController alloc] initWithContentViewController:content];
aPopover.delegate = self;
[content release];
// Store the popover in a custom property for later use.
self.popoverController = aPopover;
[aPopover release];
[self.popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
Getting this crash:
2011-08-16 23:59:55.730 Codes[3646:707] -[DetailViewControlleriPad showBookmarksMenu]: unrecognized selector sent to instance 0x191220
2011-08-16 23:59:55.757 Codes[3646:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailViewControlleriPad showBookmarksMenu]: unrecognized selector sent to instance 0x191220'
The showBookmarksMenu: method is being called on DetailViewControlleriPad, whereas it should be called on the class which implements it.
Ensure that the method is properly hooked in IB.
Your showBookmarksMenu: method is not found by the class and that's why it is crashing your application. Check your source code and try again. Have a happy coding. :)
I've tried to ask this before, but nothing got answered. Basically, I would like someone to explain to me how to create a table, which when a cell is tapped, pushes the user to the next view for that cell. I have this so far:
Click here to view what I have.
I would further like to, say when CSS is tapped, it goes to a new view which has another table in it. This table would then take the user to a detail view, which is scrollable and you can switch pages through it.
I would appreciate longer, more structured tutorials on how to do each and every bit to get it to work.
Here's my array in my implementation file:
- (void)viewDidLoad {
arryClientSide = [[NSArray alloc] initWithObjects:#"CSS", #"HTML", #"JavaScript", #"XML", nil];
arryServerSide = [[NSArray alloc] initWithObjects:#"Apache", #"PHP", #"SQL", nil];
self.title = #"Select a Language";
[super viewDidLoad];
}
and my .h:
#interface RootViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
IBOutlet UITableView *tblSimpleTable;
NSArray *arryClientSide;
NSArray *arryServerSide;
}
My current code crashes the script, and this error is returned in the console:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "NextView" nib but didn't get a UITableView.'
If that error is the source of why it's not pushing, then an explanation of how to remedy that would also be appreciated
NextViewController implementation
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
arryBasicCSS = [[NSArray alloc] initWithObjects:#"Implement", #"Syntax", #"Classes and IDs", #"Fonts", #"Backgrounds", #"Lists", #"Links", nil];
arryIntermediateCSS = [[NSArray alloc] initWithObjects:#"Padding and Margin", #"Alignment and Floating", #"Pseudo-class and Element", #"Opacity and Display", nil];
arryAdvancedCSS = [[NSArray alloc] initWithObjects:#"Sprites", #"Attribute Selectors", #"Animation", nil];
self.title = #"CSS";
[super viewDidLoad];
}
- (IBAction) changeItemTable:(NSString *)str{
tblCSS = str;
}
NextViewController.h
#interface NextViewController : UITableViewController {
IBOutlet UITableView *tblCSS;
NSArray *arryBasicCSS;
NSArray *arryIntermediateCSS;
NSArray *arryAdvancedCSS;
}
Many thanks,
Jack
First the "Terminating app due to uncaught exception" error. I noticed that your RootViewController contains:
IBOutlet UITableView *tblSimpleTable;
Check to make sure that you have properly connected RootViewController's "view" property to your UITableView, and not just connected tblSimpleTable to your TableView. The view property in a UITableViewController needs to point to a UITableView.
Assuming that tblSimpleTable is the TableView that you want to control from this UIViewController, delete this outlet and just use the "view" or "tableView" property of the UITableViewController, they will both be valid.
For your original problem of hierarchical table views, have at look at this sample project:
TheElements
If the SDK's own documentation isn't providing the answers you need, try a Google search for UITableView Interface Builder tutorial. That should return a number of useful step-by-step tutorials.
The reason you're getting the exception is because you haven't connected your tblSimpleTable outlet to your table view object in Interface Builder.
Open NextView.xib in Interface Builder. Select the File's Owner object. Open the Inspector pane, and you should see something similar to the image I've posted. Instead of "searchTable" yours should read "tblSimpleTable". To connect the outlet to the file's owner, click-and-hold on the circle to the right of "tblSimpleTable" and drag the line to your "tblSimpleTable" object.
Save your changes, rebuild your project.
See this:
http://adeem.me/blog/2009/05/19/iphone-sdk-tutorial-part-2-navigation-in-uitableview/