losing sleep over this issue
My app hierarchy is ListVC1-->ListVC2-->DetailVC. [Working perfect]
and... SearchListVC-->DetailVC (the same DetailVC as above) [Issue is in this model]
The code in SearchListVC is almost same as ListVC2, with a difference that it contains a SearchBar, instead of a navigationBar, on top.
Also, please note that I am able to present the DetailVC as a ModalView, it is push that is not happening... the cell remains highlighted.
Here is the didselectrow code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
// Navigation logic may go here. Create and push another view controller.
if (indexPath.row<[smses count]) {
WebSMSDetailViewController *detailViewController = [[WebSMSDetailViewController alloc] initWithNibName:#"WebSMSDetailViewController" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
detailViewController.smsList = allWebSMSes;
detailViewController.smsIndex = indexPath.row;
[detailViewController populateDetails];
[detailViewController release];
}
else {
if (indexPath.row<totalSMSes) {
pageNumber++;
[self loadNotes];
}
}}
I think the problem is somewhere else.
I have been googling for quite a while but couldn't understand the solutions posted, so please be a little descriptive... beginner here!
I suppose the problem is that, you dont have a navigation controller in the SearchListVC.
Like you wrote,
it contains a SearchBar, instead of a navigationBar, on top
Use a navigation controller with the SearchListVC and I think your problem is solved.
Cheers
You just create/use #property for the navigationBar
or u have to place the Navigationbar on the top of the view and place your search bar on the bottom of the navigationBar
Related
I'm presenting a modalViewController with UIModalTransitionStyleCoverVertical and then, when the user selects a row of this modalView, I present another modalView as follows:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
CenterViewController *nextView = [[CenterViewController alloc] init];
nextView.modalPresentationStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:nextView animated:YES];
[nextView release];
}
The problem is that the transition style remains UIModalTransitionStyleCoverVertical no matter what type of transition style mode I initialize for this second modal view controller.
Am I missing something relevant?
Thanks in advance.
UIModelPresentaionStyle is used to tell iOS you want it FullScreen or PageSheet..etc. , in your case you should use UIModelTransitionStyle .. so if you did like this it should work.
nextView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
I'd try removing the old one first, and then presenting the new one.
Doesn't sound like a great technique though. Why not have you first modal view controller be some sort of container controller, and present the new view with a flip.
In viewDidLoad I add a tableview to navigationController like this :
[self.view addSubview:navigationController.view];
[self.navigationController.view addSubview:tableViewRecherchePartenaire];
When a row from tableview is selected I want this tableview to disappear and I tried something like this :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==0){
NSLog(#"RecherchePartenaireTypePartenaireViewController...");
[self.navigationController.view removeFromSuperview];
recherchePartenaireTypePartenaireViewController=[[RecherchePartenaireTypePartenaireViewController alloc] init];
recherchePartenaireTypePartenaireViewController.recherchePartenaireViewController=self.view;
[self.navigationController pushViewController:recherchePartenaireTypePartenaireViewController animated:YES];
[recherchePartenaireTypePartenaireViewController release];
}
}
but the tableview disappear but the next view is not appear. How can I use the table view with the navigationController ? Please help...I spent a lot of time with this and I can see the mistake..Thanks in advance..
First of all, you must not add subview to UINavigationController's view. Put your UITableView in a subclass of UIViewController and make it the rootViewController of your navigationController. You can do it in your main xib file or programmatically :
navigationController.rootViewController = myTableViewController;
After you can almost keep your function :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row==0){
NSLog(#"RecherchePartenaireTypePartenaireViewController...");
recherchePartenaireTypePartenaireViewController=[[RecherchePartenaireTypePartenaireViewController alloc] init];
[self.navigationController pushViewController:recherchePartenaireTypePartenaireViewController animated:YES];
[recherchePartenaireTypePartenaireViewController release];
}
}
But this function will be in myTableViewController.
In your code, you were removing your navigationController's view from the view hierarchy. So it's normal that nothing came up when you were pushing something, because UINavigationController handle push by pushing the next controller's view on it's own view.
Here is a nice Apple's sample that could help you :)
http://developer.apple.com/library/ios/#samplecode/TheElements/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007419
In your code uitableview is not a navigation type view.So,When you are adding the UITableview to the navigationcontroller's view,superview is uitableview.Ans in didselectrowAtIndexPath you are pushing on the UITableview but not on the NavigationController.So make the UITableview as navigationtype.And then add it to navigationController.And do the same whatever you did.
i have an application where a there is a root view controller which pushes another a view controller into view. this view controller shows a table. when a cell is selected, it pushes to another view controller.
The first push works, but the second doesn't.
Here is my code for the selection of the cell in the table:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
TwoViewController *two = [[TwoViewController alloc] initWithNibName:#"TwoViewController": bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:two animated:YES];
[two release];
Any idea what i've done wrong? the codes I've used for both pushes are nearly identical...
I've tried this with putting this code in the touchUpInside event for a UIButton as well, but it does not work.
My guess is that there is no navigationController to push the view, but I don't know.
Please help!
Did you change the -initWithNibName:bundle method on TwoViewController? My guess is it doesn't initialize correctly (i.e.: the method doesn't initialize the super class correctly).
Edit: I think I found the error, it's kind of obvious, actually.
Please check this code you posted:
initWithNibName:#"TwoViewController": bundle:[NSBundle mainBundle]];
The error is near the #"TwoViewController": string, an extra semicolon that should not be there, change it to:
initWithNibName:#"TwoViewController" bundle:[NSBundle mainBundle]];
Log both 'two' and self.navigationController,
NSLog(#"two = %#", two);
NSLog(#"self.navigationController = %#", self.navigationController);
First you'll get to know, if one of them is nil (or both) and whether tableView:didSelectRowAtIndexPath: gets called at all.
Its navigation controller problem.Check it properly
If the new view controller is part of a view, it probably doesn't have a navigation controller. Check if navigation controller is nil before pushing.
I can post code, though I'm not quite sure where to start. I have a UITableView with custom cells, in the middle tier of a three-level UINavigationView scheme. When I drill down to the bottom level and see details about my data, then use the top-left back button, my table view comes back scrolled all the way to the top, rather than scrolled down to where it was when I last saw it. Where should I look about this?
EDIT:
Here's the code in the EventsTableViewController to load an instance of EventsDetailViewController and push it on the navigation controller:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSMutableArray *events = [DataManager sharedDataManager].eventList;
Event *selectedEvent = [events objectAtIndex:[indexPath row]];
EventsDetailViewController *detailController = [[EventsDetailViewController alloc] initWithNibName:#"EventsDetailView" bundle:nil];
[detailController loadEvent:selectedEvent];
MyAppDelegate *del = (MyAppDelegate *)[UIApplication sharedApplication].delegate;
[del.navigationController pushViewController:detailController animated:YES];
[detailController release];
}
There's nothing in my EventsTableViewController about reloading the table, as far as I can see--I haven't implemented viewWillAppear or viewDidLoad or any of those.
Are you by any chance reloading the table where you shouldn't be? In the ViewWillAppear method for example?
I was accidentally instantiating a new copy of my table view whenever I hit this level of the navigation. That's all fixed now and this isn't a problem anymore.
I have a very similar question. When I go to the chatView, which is a UIViewController belonging to the navigationController and has a tableView as a subview, and then I scroll to some point, and then I go back, and then I go back to the chatView, it starts at the top again. I am allocing the tableView in loadView of the chatView, so the tableView gets realloced everytime I come back. But, isn't this standard? How do I just always scroll to the bottom like the iPhone Messages app and show the scroll bar for a few seconds at the bottom?
Here's the code:
http://github.com/acani/acani-chat/blob/master/Lovers2/Classes/ChatViewController.m#L184
Thanks!
Matt
are you doing:
[self presentViewController:navController animated:YES completion:nil];
where self is tableviewcontroller? give this a try:
[self.navigationController presentViewController:navController animated:YES completion:nil];
I have a tabbed bar main window with four tabs, one of which is a list. This list is empty at first but when I click a "+" I am presented with a modal view of available options like this
- (IBAction)addThing:(id)sender {
MJAvailableThingsViewController *controller = [self availableThingsViewController];
[self presentModalViewController:availableThingsViewController animated:YES];
[controller setEditing:YES animated:NO];
}
This works.
The list of things has a UITableViewCellAccessoryDetailDisclosureButton on each row. This was done with the accessoryTypeForRowWithIndexPath. This works as well.
When I click the little blue button in this view the delegate accessoryButtonTappedForRowWithIndexPath is called. This works.
However, in accessoryButtonTappedForRowWithIndexPath I want to present a detail view of the thing and this is where I encounter problems:
The delegate looks like this:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;
{
NSLog(#"accessoryButtonTappedForRowWithIndexPath");
NSLog(#"Tapped row %d", [indexPath row]);
[[self navigationController] pushViewController:thingDetailViewController animated:YES];
The program enters this code but nothing happens, that is I get the NSLog output but no new window. I am very new at this so please forgive me if this is obvious; to me it is, however, not... :-)
Do you have a navigationController? It sounds like you have a TabController but not a NavigationController.
Check [self navigationController], is it set to anything?
Here's a similar question:
Tab Bar Application With Navigation Controller