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.
Related
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"];
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];
I am trying to create an array of views that I can then swipe though in my applicant.
I have tried to set up my array in my view did load then load the first view in the array into view.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = #"Prototype";
//Initalizse the swipe gestuer listener
[self setupLeftSwipeGestureRecognizer];
[self setupRightSwipeGestureRecognizer];
//alloc and init viewcontroller nibs
self.detailViewA = [[DetailViewController alloc]initWithNibName:#"DetailViewController" bundle:[NSBundle mainBundle]];
self.detailViewB = [[DetailViewControllerB alloc]initWithNibName:#"DetailViewControllerB" bundle:[NSBundle mainBundle]];
self.detailViewC = [[DetailViewControllerC alloc]initWithNibName:#"DetailViewControllerC" bundle:[NSBundle mainBundle]];
// Create Array
viewArray = [NSArray arrayWithObjects:detailViewA_, detailViewB_, detailViewC_, nil];
// set detail View as first view
[self.view addSubview:[viewArray objectAtIndex:0]];
}
After which it crashes. and produces this message.
2012-05-31 10:06:33.769 SMPrototypeB[2394:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailViewController superview]: unrecognized selector sent to instance 0x131b00'
You are adding a view controller as a subview but what you need to do is add the view of that viewController.
UIViewController *tempVC = (UIViewController*)[viewArray objectAtIndex:0];
[self.view addSubView:tempVC.view];
i use this code
- (IBAction)gotostatuttableviewcontroller:(id)sender
{
[self.statutsField resignFirstResponder];
StatusTableViewController *statuttableview =[[StatusTableViewController alloc]initWithNibName:#"StatusTableViewController" bundle:nil];
statuttableview.Flynumber=statutsField.text;
[statuttableview.Flynumber retain];
[self.navigationController pushViewController:statuttableview animated:YES];
}
and this is my interface in interface builder http://hpics.li/19cc67b
But when i build , i have this
http://hpics.li/188d87e
Why the tableview don't have the same seize that i puted in interface builder ? It's becaus it' a UItableViewcontroller class and not UIViewCotroller ?
#CharlieMezak i do it and now i have this error
Terminating app due to uncaught
exception
'NSInternalInconsistencyException',
reason: '-[UITableViewController
loadView] loaded the
"StatusTableViewController" nib but
didn't get a UITableView.'
in this line ( pushviewcontroller)
StatusTableViewController *statuttableview =[[StatusTableViewController alloc]initWithNibName:#"StatusTableViewController" bundle:nil];
statuttableview.Flynumber=statutsField.text;
[statuttableview.Flynumber retain];
[self.navigationController pushViewController:statuttableview animated:YES];
Thank you
Look at your nib file. Check that the File's Owner view outlet is connected to the top level UIView and not to the UITableView. If it's connected to the table view, then the table view will be treated as the view controller's view. The containing views will be ignored.
Try setting the frame of the UITableView in viewDidLoad.
Compiling my application works—everything is fine. The only errors I get are by deprecated functions (setText).
The only problem is now, is that when I tap on a cell in my table, the app crashes, even though it's meant to push to the next view in the stack.
Any solutions are appreciated, if you need any code, just ask.
Also, how can I only make sure that one cell goes to only one view? For example:
When I tap on CSS, it takes me to a new table with different levels of CSS. WHen I tap on an item in that new view, it comes up with an article on what I just selected.
Regards,
Jack
Here's my code at the didSelectRowAtIndexPath method:
-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row==0){
NextViewController *nextController = [[NextViewController alloc]
initWithNibName:#"NextView" bundle:nil];
[self.navigationController pushViewController:nextController
animated:YES];
[nextController changeItemTable:[arryClientSide
objectAtIndex:indexPath.row]];
}
}
#end
(as requested in the comments).
When we create new UIViewControllerSubClass with xib-interface, xib file is created as sourcecode.xib (can be seen in get info of that xib file): Change sourcecode.xib to "file.xib" and see the magic :)
Terminating app due to uncaught
exception
'NSInternalInconsistencyException',
reason: -[UIViewController
_loadViewFromNibNamed:bundle:] loaded the "NextView" nib but the view outlet
was not set.'
Open NextView with Interface Builder
Set Class value at : "NextViewController" to your File's Owner
Connect the View outlet (Ctrl click and drag - a blue line should appear - from the File Owner to the UIView and select "view" in options)
you need to update your code like this :
-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row==0){
NextViewController *nextController = [[NextViewController alloc]
initWithNibName:#"NextView" bundle:nil];
[nextController changeItemTable:[arryClientSide
objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:nextController
animated:YES];
}
else{ }
}
try using this code...
Error description from comments:
Terminating app due to uncaught
exception
'NSInternalInconsistencyException',
reason: '-[UIViewController
_loadViewFromNibNamed:bundle:] loaded the "NextView" nib but the view outlet
was not set.'
If your view controller is loaded from nib file and its view is not set exception then exception is thrown. So when you create your view in IB you must connect view outlet to your view controller object (likely - file owner in IB).
Edit: So basically in IB in your nib file you need to do the following:
1. set file owner's type to NextViewController
2. connect NextViewController's view outlet to a View object
release that NextViewController you alloc!
[nextController release];
It's leaking.
Don't use IB. Instead, make alloc init with nothing, then in load view:
self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];