Select table view in editing mode - objective-c

I want to push two different view controllers: 1). When tableView is in "normal mode" 2). When the table view is in editing mode. The edit button is on my navigation bar. When the Table View is in "normal mode" I can select a cell, It turns blue and pushes my View Controller. How can I make it so that the table view is able to be selected while in edit mode? Here is what i have done so far:
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *detailViewController = [[DetailViewController alloc] initForNewItem:NO];
[detailViewController setItem:selectedItem];
//This doesnt work because i cant select the cell
if(aTableView.editing){
[[self navigationController] pushViewController:detailViewController animated:YES];
} else {
//push something else
}

Maybe you should set the UITableView property allowsSelectionDuringEditing to YES (by default it's NO). Try to set it in the LoadView, not in the init.

Related

View gets pushed down when performing segue with a visible navigation bar

I'm performing a segue with a navigation bar over a view that has the navigation bar hidden, when the segue starts my current view seems to get pushed down by the navigation bar that is not hidden in my segue… which looks bad…
If I remove the setNavigationBarHidden:animated method I don't see a navigation bar after performing the segue, and the issue doesn't manifest anymore.
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.navigationController setNavigationBarHidden:NO animated:YES];
if (indexPath.row == 0) {
[self performSegueWithIdentifier:#"mailSignUp" sender:nil];
} else if (indexPath.row == 1) {
[self performSegueWithIdentifier:#"logIn" sender:nil];
}
}
If you want to hide your navigation bar you have to do it in the root controller, the first controller in your app.
My guess is that you have had setup a modal segue in interface builder from a certain button to the following view. By doing so you have the following view sliding in from down to top.
I'm also guessing you are using the lastest xcode version [4.5.2] and running it on ios6.
Try deleting your segue from interface builder. Also, instead of your:
[self performSegueWithIdentifier:#"mailSignUp" sender:nil];
use:
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
YourSecondController *secondController = (YourSecondController *)[storyBoard instantiateViewControllerWithIdentifier:#"YourSecondController"];
[self.navigationController pushViewController:yourSecondController animated:YES];
[substitue YourSecondController with mailSignUp or whatever controller you want to perform segue to]
Also, if you want to hide your navigation bar you have to add this line of code in your (void)viewdidload method in your root controller.
If you run your segue programmatically like this, you should achieve your second view slide from right to left. Let me know if this helped or provide more info if it is not sufficient or exact.

Transition to a view in table with dynamic cells

I create tableview and I fill the table dynamic data.
How to create transition between cell and another view.
Сells are filled with the names of files in the folder documents.
I use storyboard.
App for iPad.
You can make transition from cell to another view using following code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
anotherView *obj =[[anotherView alloc]initWithNibName:#"anotherView" bundle:nil];
[self.navigationController pushViewController:obj animated:YES];
[obj release];
}
this method is a delegate method of tableview and when you will select any cell ,it will be called and will go to another view

unable to create a back button when navigate from a table view to another

this is a newbie question.i ve created a grouped tableview .on clicking the tableview cell it navigates to a new view.but i m unable to create a back button.I even added a navigation bar in the second view of the nib file.but its of no effect..could you guys help me out..below is the screenshot and code of the first view
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
if (indexPath.row==0) {
self.dvController1 = [[FirstView alloc] initWithNibName:#"FirstView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController1 animated:YES];
}
if (indexPath.row==1) {
self.dvController2 = [[Tab4 alloc] initWithNibName:#"Tab4" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController2 animated:YES];
}
}
In the presented controller add a button with an IBAction in it:
- (IBAction)back:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
And make sure that you have a navigationController indeed (meaning that your application needs to be navigation oriented, meaning that you need to instantiate the navigationController property in the application delegate)
In your second view .put this code in viewDidLoad method
self.navigationItem.leftBarButtonItem.title = #"Back";
just hide the bar in the viewWillAppear method & unhide the bar in viewWillDisAppear methods of the tableViewController class. By using
self.navigationController.navigationBarHidden = YES/NO;

How to load a table from a .nib when an item in a previous table is selected?

At the moment, I have an iOS app that starts out with a NavigationView (root view) and a table contained in the root view below the navigation bar. I am attempting to load another view (hoping to make it another table) from a .nib file when the first row in the original table is selected. How can I do this?
Any help or advice would be appreciated. Thank you very much.
You need to make use of the UITableViewDelegate method, tableView:didSelectRowAtIndexPath:
Ensure that your tableview's delegate is set to your view controller inside Interface Builder, or if you are not using interface builder..
[tableView setDelegate:self];
Your view controller will then adopt the UITableViewDelegate protocol and respond to tableView:didSelectRowAtIndexPath: when a row is selected.
Loading your new view when the first row is selected will be implemented like so..
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.section == 0){ // the first row
MyView *myView = [[MyView alloc] init];
[self.navigationController pushViewController:myView animated:YES];
[myView release];
}
}

My table view does not navigate to another uiview page. What might be wrong?

My table view cells have the ContentView as the Labels. When I click on them to navigate to another view whose viewController is as shown does not navigate.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailedWebViewController *detailedWebViewTab1=[[DetailedWebViewController alloc] initWithNibName:#"DetailedRssWebView" bundle:Nil];
[self.navigationController pushViewController:detailedWebViewTab1 animated:NO];
[detailedWebViewTab1 release];
}
on tap it stays where it is highlighting the table in blue.
the object for the XIB is being created but cannot navigate to it.
Try to check in debugger if your detailedWebViewTab1 is really not nil. It seems to be so according to your description.