Transition to a view in table with dynamic cells - objective-c

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

Related

iOS - Connect UITableViewCell to another ViewController Programmatically

I have programmatically created a tableView populated it with some rows. However, I was wondering upon tapping one of these cells how could I navigate to another view controller while passing data to the other viewController as well?
This is what I filled each cell with:
cell.textLabel.text = [NSString stringWithFormat:#"#%#", currentAccount.username];
How do I pass currentAccount.username to another viewController I just created? I am not using storyboards as I had created the UITableView programmatically. However, I have created another view controller called FeedViewController.
In your table view delegate method:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
you would instantiate your FeedViewController, pass any data to it using its properties and then display it.
Something like:
FeedViewController* feedVC = [[FeedViewController alloc] init];
feedVC.username = currentAccount.username
[self presentViewController:feedVC animated:YES completion:nil];

Select table view in editing mode

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.

UIWebView on top of UINavigationController stack not shown

I have a UIViewController "PdfViewController" with a view containing an UIScrollView wich is containing an UIWebView, designed by storyboard. I'm using storyboard in Xcode 4.2 with ARC.
If I start PdfViewController as initial ViewController the webview is shown as expected.
I want the PdfViewController to show a PDF from a list of PDF's. So I made a NavigationController containing a TableViewController with the document titles.
If I try to show the PdfViewController by "tableView didSelectRowAtIndexPath" the view stays black and doesn't load the selected document.
There is no errer message from Xcode.
The viewDidLoad and the viewWillAppear from PdfViewController get called.
Here the initialisation of the PdfViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
PdfViewController *pdfViewController = [[PdfViewController alloc]init];
[pdfViewController setFileName:#"test"];
[self.navigationController pushViewController:pdfViewController animated:YES];
}
-It seems, the problem is that the PdfViewController does not load the corrsponding nib by itself.
If I make a seque from the TableViewCell, the PdfViewController is loaded correctly.
I changed the code to:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.navigationController.viewControllers.lastObject setFileName:#"test"];
}
The only thing to know here, is that the viewDidLoad und viewWillAppear are called before the execution of tableView didSelectRowAtIndexPath, so the PDF has to be loaded in viewDidAppear.
With Xcode 4.2 or later, you can pass the data between two view controllers via segue.
Please Check:
How to pass prepareForSegue: an object
Your code may look like this:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
if ([[segue identifier] isEqualToString:#"__YOUR_SEGUE_STRING__"]) {
PdfViewController *pdfViewController =
(PdfViewController*)[segue destinationViewController];
//
// write your code here
//
[pdfViewController setFileName:#"test"];
}
}

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.