iOS Development click Tableviewcell, Show Details

Source: Internet
Author: User
Tags uikit

Describes a method for creating segue on a storyboard drag control.

First to translate the next segue

Source: https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/UsingSegues.html

Definition: Segue represents a conversion (?) between two Viewcontroller in the storyboard file. A view controller's buttons, table rows, or gestures typically point to the B-View controller.

Trigger: Implemented by Uikit, you can use notifications to transfer data between A and B. Segue is triggered after the workflow is as follows

Provides Shouldperformseguewithidentifier:sender: method to abort the steps required for a jump, such as not creating new segue and B;

Provides Prepareforsegue:sender: method to transfer data.

Type: The original table as follows, a few segue difference is: Show is a b heap on a, detail with B replacement a,modally with a template display B,popover with B as the pop-up window.

Table 9-1Adaptive Segue Types

Segue type

Behavior

Show (Push)

This segue displays the new content using the showViewController:sender: method of the target view controller. For more view controllers, this segue presents the new content modally over the source view controller. Some View controllers specifically override the method and use it to implement different behaviors. For example, a navigation controller pushes the new view controller onto its navigation stack.

UIKit uses the targetViewControllerForAction:sender: method to locate the source view controller.

show Detail (Replace)

this segue displays the new con Tent using The showdetailviewcontroller:sender:  method of the Target View Controller. This segue are relevant only for view controllers embedded inside A  Uisplitviewcontroller  object. With this segue, a split view controller replaces it second child View controller (the detail controller) with the new Co Ntent. Most other view controllers present the new content modally.

uikit uses the targetviewcontrollerforaction:sender: method to locate the source view controller.

Present modally

This segue displays the view controller modally using the specified presentation and transition styles. The view controller that defines the appropriate presentation context handles the actual presentation.

Present as Popover

In a horizontally regular environment, the view controller appears in a popover. In a horizontally compact environment, the view controller is displayed using a Full-screen modal presentation.

Steps

1. Select cell, Associate cell with B,segue type Select Selection Show (detail)

2. Overwrite the Prepareforsegue method in a corresponding controller

Class Acontroller:uiviewcontroller, Uitableviewdatasource,uitableviewdelegate {

// ...

At present there is only one segue, so there is no judgment Viewcontrollerid, the error is to learn how to distinguish

Override Func Prepareforsegue (Segue:uistoryboardsegue, sender:anyobject?) {

Let Index:int = (self.table.indexPathForSelectedRow?. Row)!

Let data:videosummary = Videosummaries[index]

Let View:bcontroller = Segue.destinationviewcontroller as! Videoviewcontroller

View.selectedvideo = Data

}

}

3. Add the Selectedvideo property to the controller that corresponds to B

Class Bcontroller:uiviewcontroller, Uitableviewdatasource,uitableviewdelegate {

var selectedvideo:videosummary! Notice the exclamation mark,

//...

}

Success.

iOS Development click Tableviewcell, Show Details

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.