While transition the page after click, screen is going black - iphone

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];

Related

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

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"];

How i can navigate from View Controller to another View Controller once clicking on button?

I am getting this exception when I am trying to move to another view:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'NextViewController''
NextViewController *temp = [[NextViewController alloc]initWithNibName:#"NextViewController" bundle:nil];
[self presentViewController:temp animated:YES comletion:nil];
Firstly, check if you really have NextViewController.xib?
If No, then how can you load your nib file?
Also, check if you have NextViewController given as File's Owner class?
If yes,
Check, if you used have navigationcontroller?
If yes, then change your code to :
NextViewController *temp = [[NextViewController alloc]initWithNibName:#"NextViewController" bundle:nil];
[self.navigationcontroller presentViewController:temp animated:YES comletion:nil];
Exception says that you don't have the NextViewController.xib file in your project. Double check whether you have it or not.
Also make sure you have given the NextViewController as your File's Owner Class of NextViewController.xib
make sure you have the nib named NextViewController on your project. and also check if its added on your bundle resources. see screenshot
First you create uinavigationcontroller object first view set as a rootview controller after that set button on rootviewcontroller and push nextvie.
//for mainviewcontroller
UINavigationController *navigation =[[UINavigationController alloc]initWithRootViewController:viewcontroller];
[self.navigationController pushViewController:nextview animated:YES];
If you are using swift 3.0,try below code
//Here you can initiate your new ViewController
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewController(withIdentifier: "VadiveluPageViewController") as! VadiveluPageViewController
self.present(nextViewController, animated:true, completion:nil)
//if you need navigation controller use below
//self.navigationController?.pushViewController(nextViewController, animated: true)
Create 2 view controller in main story borad.
Go to main story board and select one view controller in main story board and drag and put into another view controller and select show method.
Make sure to create class and identifer name in second View Controller.
Go to Editor option and select navigation method. And put the below code in button action function.
self.performSegue(withIdentifer: "IdentiferName", sender: self)

loading a nib file that is instantiated from a storyboard

So I am pretty new to this story board concept. I have a view nibs dropped in to the storyboard and each corresponding to a UIViewController subclass I have, I tried loading the nib file using the following code:
TestViewController *vc = [[TestViewController alloc] initWithNibName:#"TestViewController" bundle:nil];
[self.view setBackgroundColor:[UIColor blueColor]];
[self.view setFrame:CGRectMake(0, self.profilePicture_.frameHeight + self.profilePicture_.frameY + 10, self.scrollView_.frameWidth, 100)];
[self.view addSubview:vc.view];
However, it gives me the following error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/aditya15417/Library/Application Support/iPhone Simulator/5.1/Applications/64E6CEC9-E6DC-4AF5-BF16-11BFB6415BDC/Pulse.app> (loaded)' with name 'TestViewController''
So the question is, if I have my nib in the story board is it not possible to use the initWithNibName? If there is a way, how do I do this?
Please use
[self.storyboard instantiateViewControllerWithIdentifier:#"some identifier you set in IB"];
Why are you loading PNRNewsfeedViewController as TestViewController? Is TestViewController the base class for PNRNewsfeedViewController? Make sure that in the nib, the File's Owner custom class is set to PNRNewsfeedViewController, and then allocate a news feed view controller:
PNRNewsfeedViewController *vc = [[PNRNewsfeedViewController alloc] initWithNibName:#"PNRNewsfeedViewController" bundle:nil];
// ...
When you use a storyboard, you don't use individual nibs directly, and you don't instantiate view controllers yourself. You can use the UIStoryboard class to instantiate a view controller from the storyboard as described in the documentation.
This is the way I'd do it:
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:[NSBundle mainBundle]];

resize UItableView

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.

iPhone: App crashes when I click on a cell in table view

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];