i can't navigate to the other view in (didSelectedRowAtIndexPath) - iphone

When i click on row to navigate to the other view it give me crash
"Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<detailInfo 0x6b503d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key lblText.'
*** First throw call stack:
"
This is my code :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
_vcontroler = [ urls objectAtIndex:indexPath.row];
if (!self.detailViewController)
{
self.detailViewController = [[[detailInfo alloc] initWithNibName:#"detailInfo" bundle:nil] autorelease];
}
detailViewController.vcontroler =_vcontroler;
[self.navigationController pushViewController:self.detailViewController animated:YES];
[detailViewController release];
}

The problem is that you removed an graphical object from view's frame without removing outlet connection. Select your view controller's .xib, then select File's Owner (left click on it) and remove outlet connection for lblText object. Build & run. It should be fine.

Related

Trying to pass from TableView to UIWebview causes crashes

As you can read in the title, I am having a slight problem. I am using the MWParser for an RSS feed. I edited the code for when you click on an RSS title, it opens in an in-app browser.
This is the code:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (_webViewController == nil) {
self.webViewController = [[[WebViewController alloc] initWithNibName:#"WebViewController" bundle:[NSBundle mainBundle]] autorelease];
}
MWFeedItem *entry = [parsedItems objectAtIndex:indexPath.row];
_webViewController.entry = entry;
[self.navigationController pushViewController:_webViewController animated:YES];
// Deselect
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
However, I get this crash message:
2013-02-11 18:21:15.644 GlennKessler[24209:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/Hugo/Library/Application Support/iPhone Simulator/6.1/Applications/7F35D6C0-BFBE-4CD9-A1CE-7DC54CD6B249/GlennKessler.app> (loaded)' with name 'WebViewController''
From what I can tell, this is happening because I am using Storyboards, not NIBs. How do I have it open the view in the storyboard that is running off of the code in WebViewController? Thanks!
Replace the [NSBundle mainBundle] by nil since the nib is in the default bundle, and make sure that the nib file (WebViewController.nib) is in the Bundle you are packaging the app

Error when trying to load next View from nib

This is what I'm trying to do in TalbeViewController.m:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:TRUE];
if(indexPath.row==0) {
//Initialize the detail view controller and display it.
OmDetail1ViewController *firstDetailController = [[OmDetail1ViewController alloc] initWithNibName:#"OmDetail1ViewController" bundle:nil];
[self.navigationController pushViewController:firstDetailController animated:YES];
[firstDetailController release];
}
else if(indexPath.row==1) {
//The second DetailView
}
else if(indexPath.row==2) {
//The third DetailView
}
}
And this is what I'm told when the first cell is selected:
2012-07-17 14:17:42.660 TheApp[4635:f803] * * * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'OmDetail1ViewController''
* First throw call stack:
(0x13d5022 0x1566cd6 0x137da48 0x137d9b9 0x240638 0xe61fc 0xe6779 0xe699b 0xe6d11 0xf88fd 0xf8aef 0xf8dbb 0xf985f 0xf9e06 0xf9a24 0x2f90 0xb05c5 0xb07fa 0x94585d 0x13a9936 0x13a93d7 0x130c790 0x130bd84 0x130bc9b 0x12be7d8 0x12be88a 0x1f626 0x28c2 0x2835)
terminate called throwing an exception(lldb)
I've done nothing else to connect the views except importing "OmDetail1ViewController.h" in TableViewController.m.
In the IB I've set the correct Class in the utilites but done nothing more, made no connections or so.
The problem is not in that piece of code. But rather in your OmDetail1ViewController class, check that you have set the view correctly in IB for the ViewController, and that the name matches.
In IB your view should be set to "Files Owner" and if you select Files Owner, in the Custom Class it should have your OmDetail1ViewController class.

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

Cannot push TTTableViewController onto Navigation Controller

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.

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