Click a row in TableView to go to the next page. Click tableview.

Source: Internet
Author: User

Click a row in TableView to go to the next page. Click tableview.

The TableView control is very common in iOS development. It can better display a hierarchical structure. This section describes how to jump to the next page when you click an entry. The following is an official process about how to implement this jump and how to transmit data.

  

Storyboards make it easy to pass data from one scene to another via the prepareForSegue:sender: method of the UIViewController class. This method is called when the first scene (the source) is about to transition to the next scene (the destination). The source view controller can implement prepareForSegue:sender: to perform setup tasks, such as passing information to the destination view controller about what it should display in its table view. Listing 3-1 shows one implementation of this method.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{if ([[segue identifier] isEqualToString:@"ShowDetails"]) { MyDetailViewController *detailViewController = [segue destinationViewController];    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];    detailViewController.data = [self.dataControllerobjectInListAtIndex:indexPath.row];} }
A segue represents a one-way transition from a source scene to a destination scene. One of the consequences of this design is that you can use a segue to pass data to a destination, but you can’t use a segue to send data from a destination to its source. To solve this problem, you create a delegate protocol that declares methods that the destination view controller calls when it needs to pass back some data.

 

  


In iphone development, tableviewcell pushes a page using segue. How can I perform other operations without redirecting when I click the first line?

Rewrite this method:

-(Void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath
{} Can achieve the corresponding jump, call [self. navigationController pushViewController: ViewController animated: YES]; this method is enough
If you want to use segue:
-(Void) prepareForSegue :( UIStoryboardSegue *) segue sender :( id) sender
This sender is the event source, UITableViewCell * cell = (id) sender;
If ([cell reuseIdentifier] = @ "first ")
....
You need to set CellIdentifier of the first cell independently in cellForRowAtIndexPath, and then judge whether it is the first cell.

In tableView, how does one switch the focus by clicking a key on the keyboard for multiple textfields?

Switching focus is actually to change this TextField to the first response.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.