UITableViewCell's reuse identifier not recognized only when launching from RESideMenu - iphone

Here is the link to RESideMenu, what I'm using in my project
To put it simply, when I make my UITableView the root viewcontroller and launch it, it works just fine. All my custom UITableViewCells are there and look great. The issue is, whenever I try and launch the UITableView from the RESideMenu. When I do, I get this error:
2013-07-06 11:49:07.844 halocustoms[4438:c07] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:],
/SourceCache/UIKit_Sim/UIKit-2380.17/UITableView.m:4460 2013-07-06 11:49:07.845 projectcf32[4438:c07]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier CustomCell -
must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
I have checked my reuse identifier on my Storyboard about a hundred times, and it must work because when the app launches initially everything is fine. It's just when selecting the UITableViewController from the RESideMenu.
Note, this is how RESideMenu displays the viewcontroller:
RESideMenuItem *homeItem = [[RESideMenuItem alloc] initWithTitle:#"Quick Games" action:^(RESideMenu *menu, RESideMenuItem *item) {
[menu hide];
MyTableView *viewController = [[MyTableView alloc] init];
viewController.title = item.title;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[menu setRootViewController:navigationController];
}];
Thanks a lot!

MyTableView *viewController = [[MyTableView alloc] init];
should be:
MyTableView *viewController = (MyTableView *)[self.storyboard instantiateViewControllerWithIdentifier: #"yourIdentifier"];

Related

Nib Load Failed

In my application, I made custom tab bar having 5 tabs, each tab shows different UIViewController.
Application is for iPhone only, so i made 2 NIBs for each UIViewController (if class name is DayView, NIBs are DayView_iPhone and DayView_iPhone5). Everything is working fine for up to 10 mins in the device as well as in simulator.
After that app is crashing showing this in console :
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/kalyanasadinagarajugari/Library/Application Support/iPhone Simulator/6.1/Applications/0DEBB118-BA67-440F-BA70-79ED41AC9134/CalendarBlender.app> (loaded)' with name 'DayView_iPhone''
I checked the NIB names also, every NIB file name is correct.
And my code is
NSString *nibName = [AppDelegate fetchNibWithViewControllerName:#"DayView"];
dayView = [[DayView alloc] initWithNibName:nibName bundle:nil];
if (IS_IPHONE_5)
dayView.view.frame = CGRectMake(0, 44, 320, 463);
else
dayView.view.frame = CGRectMake(0, 44, 320, 375); dayView.view.tag=2; [self.view
addSubview:dayView.view];
Try to check the Nibname (Case Sensitive) and clean the project,re run it . Did you changed the class name for all the nibs?
Use this:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
tabBarController = [[UITabBarController alloc] init];
MyViewController* vc1 = [[MyViewController alloc] initWithNibName:#"nibName" bundle:nil];
MyOtherViewController* vc2 = [[MyOtherViewController alloc] initWithNibName:#"nibName" bundle:nil];
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, nil];
tabBarController.viewControllers = controllers;
window.rootViewController = tabBarController;
}
And you can add controllers dynamically too by adding controllers in tabBarController's array of viewControllers.

While transition the page after click, screen is going black

here is my code:
I using storyboards
NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:nil bundle:nil];
newsdetail.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:newsdetail animated:YES];
I have a collectionview i fetched some datas from api and put them to the cells of collectionview. I want to get details of items that i clicked on cell but after click details doesn't work but black screen is coming.
here is my all output :
2013-06-17 14:20:30.288 xproject[7511:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/sezgindemir/Library/Application Support/iPhone Simulator/6.1/Applications/67BC91AF-5091-4F39-A2BD-CA7E1DD0FEF0/xproject.app> (loaded)' with name 'NewsDetailViewController''
*** First throw call stack:
(0x1c99012 0x10d6e7e 0x1c98deb 0x236ef9 0xfb7e7 0xfbdc8 0xfbff8 0xfc232 0x107c25 0x3073a3 0x104ee3 0x105167 0x1051a7 0x4c3d 0x51c42f 0x52e182 0x52e394 0x10ea705 0x12893c 0x1289ac 0x10ea705 0x12893c 0x1289ac 0x2e21d3 0x1c61afe 0x1c61a3d 0x1c3f7c2 0x1c3ef44 0x1c3ee1b 0x1bf37e3 0x1bf3668 0x1affc 0x25ed 0x2515)
libc++abi.dylib: terminate called throwing an exception
(lldb)
Is the xib for NewsDetailViewController in storyboard or separate xib?
If it is a separate xib, make sure your xib name is NewsDetailViewController.xib. Then it should work.
If the nib is in storyboard the
first set the storyboardID of the xib to NewsDetailViewController and then use
NewsDetailViewController *newsdetail=[[self storyboard] instantiateViewControllerWithIdentifier:#"NewsDetailViewController"];
newsdetail.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:newsdetail animated:YES];
You're not loading view controller properly.
Try this code:
UIViewController *vc=[[self storyboard] instantiateViewControllerWithIdentifier:#"NewsDetail"];//you have to give it this name (or any) in the storyboard
[self.navigationController pushViewController:vc animated:YES];
Make sure you have a uinavigationController controlling self
I think you missed to provide the NibName
Your code
NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:nil bundle:nil];
It should be
NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:#"YOUR_NIB_NAME" bundle:nil];
Use this -
NewsDetailViewController *news detail = [[NewsDetailViewController alloc] init];

Present UIPopoverviewcontroller

I am working on a app, which uses UIPopoverController, I am getting a problem in presenting that popover, I have a UIView which is added on self.view, and a tableview added on that view, that table view has a custom cell, which includes a UITextField, on didBeganEditing method I need popover to open.
Here is the code:
table = [[UITableView alloc]initWithFrame:CGRectMake(textField.frame.origin.x,textField.frame.origin.y,200,100) style:UITableViewStylePlain];
table.tag=3;
[table setDataSource:self];
[table setDelegate:self];
[table reloadData];
UITableViewController *tableViewController= [[UITableViewController alloc] initWithStyle:UITableViewStyleGrouped];
tableViewController.tableView = table;
popOver= [[UIPopoverController alloc]
initWithContentViewController:tableViewController];
[popOver presentPopoverFromRect:popRect inView:cell permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
I will getting following exception
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.'
here you present popoverview in the cell and give the Rect to popover of UITableViewController and so you get this error.. here it have not view hierarchy so its not get window and crashed here just follow the view hierarchy.

how can i solve this error : NSInvalidArgumentException', reason: '-[ViewController viewControllers]: unrecognized selector

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

How to use didSelectRowAtIndexPath in objective-c

I have a Tab Bar with a navigation table view. My app crashes when I select a cell on my table view. I want a new viewcontroller to open when a cell is selected. My guess is that I am not pushing it correctly when didselectrowatindexpath is called. The app stays hung up for a few seconds then closes.
Does anything catch your eye with this code? Or do you have any sample code? I am using Xcode 3 with simulator 4.3.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger row = [indexPath row];
if (self.vailViewController == nil) {
VailViewController *vailView = [[VailViewController alloc] initWithNibName:#"View" bundle:nil];
self.vailViewController = vailView;
[vailView release];
}
vailViewController.title = [NSString stringWithFormat:#"%#", [resortsArray objectAtIndex:row]];
Ski_AdvisorAppDelegate *delegate = (Ski_AdvisorAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.resortsNavController pushViewController:vailViewController animated:YES];
[self.navigationController pushViewController:vailViewController animated:YES];
}
Thanks a lot!
if (self.vailViewController == nil) {
VailViewController *vailView = [[VailViewController alloc] initWithNibName:#"View" bundle:nil];
self.vailViewController = vailView;
[vailView release];
}
In this block of code is your view file actually named "View.xib" because if not this is your crash. With this error message
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'View''
So if you want to load this with initWithNibName and your files are named as such:
VailViewController.h
VailViewController.m
VailViewController.xib
you need:
VailViewController *vailView = [[VailViewController alloc] initWithNibName:#"VailViewController" bundle:nil];
However if it is a standard UIViewController subclass you should only need to do:
VailViewController *vailView = [[VailViewController alloc] init];
The above works if you just created a UIViewController subclass in Xcode and didn't change anything. The view controller knows how to load it's own view. If you had it create an .xib file for you and you deleted something in it or just arn't sure make sure the File's Owner is wired up to the root view in the .xib file in interface bulder.
I hope that helps.
Edit:
The error in your comments:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing the same view controller instance more than once is not supported
is coming these two lines in your code:
[delegate.resortsNavController pushViewController:vailViewController animated:YES];
[self.navigationController pushViewController:vailViewController animated:YES];
I should ask if these are two different navigation controllers? if so why do they need the exact same view controller pushed to them?
I would remove one of them and then it should push the view controller without error.
What is aBookDetail? It seems like you might not be pushing the VailViewController onto the stack like you think you are. The code below might be more what you want. Also, does the debugger give you any error information about the crash?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger row = [indexPath row];
if (self.vailViewController == nil) {
VailViewController *vailView = [[VailViewController alloc] initWithNibName:#"View" bundle:nil];
self.vailViewController = vailView;
[vailView release];
}
self.vailViewController.title = [NSString stringWithFormat:#"%#", [resortsArray objectAtIndex:row]];
Ski_AdvisorAppDelegate *delegate = (Ski_AdvisorAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.resortsNavController pushViewController:self.vailViewController animated:YES];
}
Ensure the vailViewController is being retained.
#property (retain) VailViewController *vailViewController;
Also, is the resortsNavController off of Ski_AdvisorAppDelegate retained? How is that property defined?
Also, is the UITableViewController the rootController of the UINavigationController? If so, you should be able to call [self navigationController]
[[self navigationController] pushViewController:detailedView animated:YES];
I typically do this in my appDelegate:
_mainTableViewController = [[MainTableViewController alloc] init];
_navController = [[UINavigationController alloc] initWithRootViewController:_mainTableViewController];