"We all love Paul Hegarty." Stanford IOS8 public class personal note TableView Delegate

Source: Internet
Author: User

Tag:ios   swift    Stanford Open Class    tableview   delegate    

The previous remark introduced TableView's DataSource, which introduces another important part of delegate.
When we click on a cell, how do we jump to another MVC?
Like adding other segue, click the cell Control key, right-connect to another MVC, then let go, select the desired segue type.


If you have other buttons on your cell, such as detail disclosure, you can also select its segue:

Then set your segue:

Then go to Prepareforsegue to set this segue:

Each case corresponds to a different identifier, note that the sender here is of the anyobject type.

To get a sender's message in prepare, or to convert the sender to its original type, these methods in prepare do not accept a anyobject type parameter.
Then provide the data to the target controller:

Let's talk about delegate:

Delegate will observe the dynamics of tableview, such as cell being clicked. When segue is not applicable, you can use this proxy method to implement the jump:

There are many other ways to delegate:

If your model changes, remember to call the Reloaddata method to update the view.

Because when the view is displayed, the two number method and the Cellfor method have been called, we need to update the view with the Reloaddata method when the model changes, this method is a heavyweight method that will update all the data, if you just change a part of the data, You can use the lightweight approach:
Reloadrowsatindexpaths.
The height of each row in the TableView must be specified, or it can be done through automatic layout. You can also set the height of the row by using the proxy method.
In addition to the proxy method, here are some ways to tableview your own:

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"We all love Paul Hegarty" Stanford IOS8 public class personal note TableView Delegate

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.