UIScrollView, UICollectionView, and UITableView attributes and methods,

Source: Internet
Author: User

UIScrollView, UICollectionView, and UITableView attributes and methods,

UIScrollView, UICollectionView, and UITableView

Relationship between them: UIScrollView is the parent class of UICollectionView and UITableView.

UIScrollView

A scrolling view control that can be used to view content much larger than the screen.

Common attributes:

ContentOffset: Area of the currently displayed area relative to the frame Vertex

ContentSize: the maximum area (canvas) that the screen can scroll)

ContentInset: Position of the contentview vertex of scrollview relative to scrollview

DirectionalLockEnabled: whether to prohibit scrolling in a certain direction

Bounces: whether there is a bullet box Effect

AlwaysBounceVertical: whether there is a rebound in the vertical direction

AlwaysBounceHorizontal: whether there is a rebound in the horizontal direction

PagingEnabled: whether paging effect exists

ScrollEnabled: whether to scroll

ShowsHorizontalScrollIndicator: whether the horizontal scroll bar is displayed

ShowsVerticalScrollIndicator: whether to display the vertical scroll bar

ScrollIndicatorInsets: the distance of a scroll indicator embedded in a closed scroll view.

IndicatorStyle: Scroll controller Style

DecelerationRate: The deceleration rate at which the user rolls out of the screen

IndexDisplayMode: // Data Display Mode

Tracking: whether the user touches the content and initializes the scrolling

Dragging: Indicates whether to start rolling.

Decelerating: determines whether the screen continues to scroll when the finger leaves the screen.

DelaysContentTouches: whether the rolling view delays processing touch and pressure events

Cancancancelcontenttouches: whether the touch content view is always tracked

MinimumZoomScale: min scaling ratio

MaximumZoomScale: Maximum scaling ratio

ZoomScale: scaling ratio

BouncesZoom: Specifies whether to play a content zoom animation when the zoom of a scroll view exceeds the maximum or minimum values.

Zooming: whether to scale

ZoomBouncing: The scaling limit is exceeded.

ScrollsToTop: whether to scroll to the top

PanGestureRecognizer: The gesture identifier currently used for slide gestures

PinchGestureRecognizer: The current gesture identifier used for scaling up/down gestures

DirectionalPressGestureRecognizer: press the gesture to move

KeyboardDismissMode: How the keyboard disappears

RefreshControl: Update Control

Common Methods

-(Void) setContentOffset :( CGPoint) contentOffset animated :( BOOL) animated; // you can specify the region of the currently displayed area relative to the frame vertex.

-(Void) scrollRectToVisible :( CGRect) rect animated :( BOOL) animated; // specifies the area of the scrolling content to make the content visible on the screen

-(Void) flashScrollIndicators; // The scroll indicator is displayed temporarily.

-(BOOL) touchesShouldBegin :( NSSet <UITouch *> *) touches withEvent :( nullable UIEvent *) event inContentView :( UIView *) view; // (the method is called by the scrolling view) to adjust the way the scroll view handles the scroll gesture

-(BOOL) touchesShouldCancelInContentView :( UIView *) view; // whether the touch can be canceled

-(Void) setZoomScale :( CGFloat) scale animated :( BOOL) animated; // you can specify the scaling ratio.

-(Void) zoomToRect :( CGRect) rect animated :( BOOL) animated; // scale the content View to the specified Rect

UICollectionView

Common attributes:

CollectionViewLayout: Layout

PrefetchingEnabled: whether to Preload

BackgroundView: Background View

AllowsSelection: whether the item can be clicked

AllowsMultipleSelection: whether to allow multiple selections

IndexPathsForSelectedItems: The selected item

NumberOfSections: How many items are displayed

VisibleCells: cell displayed on the Interface

IndexPathsForVisibleItems: indexPath of the item displayed on the current visual interface

RemembersLastFocusedIndexPath: whether to remember the last indexPath

Common Methods:

-(Instancetype) initWithFrame :( CGRect) frame collectionViewLayout :( UICollectionViewLayout *) layout; // layout is used to initialize the layout.

-(Instancetype) initWithCoder :( NSCoder *) aDecoder: // initialize through the xib File

-(Void) registerClass :( nullable Class) cellClass forCellWithReuseIdentifier :( NSString *) identifier; // register by Class

-(Void) registerNib :( nullable UINib *) nib forCellWithReuseIdentifier :( NSString *) identifier; // use xib to register

-(Void) registerClass :( nullable Class) viewClass forSupplementaryViewOfKind :( NSString *) elementKind withReuseIdentifier :( NSString *) identifier; // use class to register a Class with supplemental View

-(Void) registerNib :( nullable UINib *) nib forSupplementaryViewOfKind :( NSString *) kind withReuseIdentifier :( NSString *) identifier; // register a class with supplemental view through xib

-(UICollectionViewCell *) dequeueReusableCellWithReuseIdentifier :( NSString *) identifier forIndexPath :( NSIndexPath *) indexPath; // use identifier to reuse cell

-(UICollectionReusableView *) Metadata :( NSString *) elementKind withReuseIdentifier :( NSString *) identifier forIndexPath :( NSIndexPath *) indexPath; // obtain reuse ReusableView through Identifier

-(NSArray <NSIndexPath *> *) indexPathsForSelectedItems; // indexPath of the selected items

-(Void) selectItemAtIndexPath :( nullable NSIndexPath *) indexPath animated :( BOOL) animated scrollPosition :( UICollectionViewScrollPosition) scrollPosition; // specifies the animation and position of the selected item

-(Void) deselectItemAtIndexPath :( NSIndexPath *) indexPath animated :( BOOL) animated; // cancel the selected item

-(Void) reloadData; // refresh data

-(Void) setCollectionViewLayout :( UICollectionViewLayout *) layout animated :( BOOL) animated; // whether to dynamically set the layout

-(Void) setCollectionViewLayout :( UICollectionViewLayout *) layout animated :( BOOL) animated completion :( void (^ _ nullable) (BOOL finished) completion; // whether to dynamically set layout and callback

-(UICollectionViewTransitionLayout *) startInteractiveTransitionToCollectionViewLayout :( UICollectionViewLayout *) layout completion :( nullable UICollectionViewLayoutInteractiveTransitionCompletion) completion; // switch layout

-(Void) finishInteractiveTransition; // The layout switchover is complete.

-(Void) cancelInteractiveTransition; // cancel layout Switching

-(NSInteger) numberOfSections; // Group

-(NSInteger) numberOfItemsInSection :( NSInteger) section; // The number of items in each group

-(UICollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath :( NSIndexPath *) indexPath; // return the layout attribute of the item.

-(UICollectionViewLayoutAttributes *) layoutAttributesForSupplementaryElementOfKind :( NSString *) kind atIndexPath :( NSIndexPath *) indexPath; // return the layout attribute of the reuse view.

-(NSIndexPath *) indexPathForItemAtPoint :( CGPoint) point; // indexpath of the item to be clicked

-(NSIndexPath *) indexPathForCell :( UICollectionViewCell *) cell; // indexPath of the cell

-(UICollectionViewCell *) cellForItemAtIndexPath :( NSIndexPath *) indexPath; // cell corresponding to indexPath

-(NSArray <__kindof UICollectionViewCell *> *) visibleCells; // an array of the current visible view celsl

-(NSArray <NSIndexPath *> *) indexPathsForVisibleItems; // array of indexPath of the currently visible view items

-(UICollectionReusableView *) supplementaryViewForElementKind :( NSString *) elementKind atIndexPath :( NSIndexPath *) indexPath; // reuse view corresponding to indexPath

-(NSArray <UICollectionReusableView *> *) visibleSupplementaryViewsOfKind :( NSString *) elementKind; // currently visible reuse view Array

-(NSArray <NSIndexPath *> *) indexPathsForVisibleSupplementaryElementsOfKind :( NSString *) elementKind; // The indexPath array of the currently visible secondary View

-(Void) scrollToItemAtIndexPath :( NSIndexPath *) indexPath atScrollPosition :( UICollectionViewScrollPosition) scrollPosition animated :( BOOL) animated // scroll to the item in indexPath;

-(Void) insertSections :( NSIndexSet *) sections; // insert a group

-(Void) deleteSections :( NSIndexSet *) sections; // delete a group

-(Void) reloadSections :( NSIndexSet *) sections; // refresh a group

-(Void) moveSection :( NSInteger) section toSection :( NSInteger) newSection; // move the group

-(Void) insertItemsAtIndexPaths :( NSArray <NSIndexPath *> *) indexPaths; // insert items

-(Void) deleteItemsAtIndexPaths :( NSArray <NSIndexPath *> *) indexPaths; // delete items

-(Void) reloadItemsAtIndexPaths :( NSArray <NSIndexPath *> *) indexPaths; // refresh items

-(Void) moveItemAtIndexPath :( NSIndexPath *) indexPath toIndexPath :( NSIndexPath *) newIndexPath; // move the item

-(Void) performBatchUpdates :( void (^ _ nullable) (void) updates completion :( void (^ _ nullable) (BOOL finished) completion; // insert/delete operations at a time

-(BOOL) beginInteractiveMovementForItemAtIndexPath :( NSIndexPath *) indexPath; // whether sorting is allowed

-(Void) updateInteractiveMovementTargetPosition :( CGPoint) targetPosition; // update the position of the item

-(Void) endInteractiveMovement; // after the movement is completed

-(Void) cancelInteractiveMovement; // cancel the update (restore to the original location)

UITableView

Common attributes:

Style: tableview style

RowHeight: cell Row Height

SectionHeaderHeight: the height of the group's header line

SectionFooterHeight: group tail Row Height

EstimatedRowHeight: pre-defined Row Height

EstimatedSectionHeaderHeight: pre-defined group header height

EstimatedSectionFooterHeight: tail height of the predefined group

SeparatorInset: the offset of the split line.

BackgroundView: Background View

NumberOfSections: number of groups

VisibleCells: The currently visible cell

IndexPathsForVisibleRows: The indexPath of the visible cell

Editing: Edit

AllowsSelection: whether to allow selection in non-compiled state

AllowsSelectionDuringEditing // You can select a row in the compilation status.

AllowsMultipleSelection: whether to allow multiple selections

AllowsMultipleSelectionDuringEditing: whether to allow multiple selections in the compilation status

IndexPathForSelectedRow: indexPath of the selected cell

IndexPathsForSelectedRows: indexPath of multiple selected cells

SectionIndexMinimumDisplayRowCount; minimum sectionIndex when displaying rowcount

SectionIndexColor: change the color of a line

SectionIndexBackgroundColor: changes the background color of a row.

SectionIndexTrackingBackgroundColor: select the background color of a part.

SeparatorColor: Color of the cell line selected

SeparatorEffect: frosted glass Effect

TableHeaderView: Header View

TableFooterView: tail View

RemembersLastFocusedIndexPath: record the indexPath of the last focus

Common Methods:

-(Instancetype) initWithFrame :( CGRect) frame style :( UITableViewStyle) style; Initialization Method with frame

-(Instancetype) initWithCoder :( NSCoder *) aDecoder; // initialize through IB

-(Void) reloadData; // refresh data

-(Void) reloadSectionIndexTitles; // refresh the index bar

-(NSInteger) numberOfRowsInSection :( NSInteger) section; // number of rows in each group

-(CGRect) rectForSection :( NSInteger) section; // gets the position and size of a group.

-(CGRect) rectForHeaderInSection :( NSInteger) section; // gets the position and size of the group header of a group.

-(CGRect) rectForFooterInSection :( NSInteger) section; // gets the position and size of the end of a group.

-(CGRect) rectForRowAtIndexPath :( NSIndexPath *) indexPath; // obtain the position and size of a row.

-(NSIndexPath *) indexPathForRowAtPoint :( CGPoint) point; // The indexPath in the row determined by the vertex

-(NSIndexPath *) indexPathForCell :( UITableViewCell *) cell; // obtain the indexPath of the cell.

-(NSArray <NSIndexPath *> *) indexPathsForRowsInRect :( CGRect) rect; // obtain the indexPath array of multiple rows

-(_ Kindof UITableViewCell *) cellForRowAtIndexPath :( NSIndexPath *) indexPath; // set the cell

-(UITableViewHeaderFooterView *) headerViewForSection :( NSInteger) section; // you can specify a group header.

-(UITableViewHeaderFooterView *) footerViewForSection :( NSInteger) section; // sets the end of a group.

-(Void) scrollToRowAtIndexPath :( NSIndexPath *) indexPath atScrollPosition :( UITableViewScrollPosition) scrollPosition animated :( BOOL) animated; // scroll a row to a feature location

-(Void) scrollToNearestSelectedRowAtScrollPosition :( UITableViewScrollPosition) scrollPosition animated :( BOOL) animated; // scroll the selected row to a specific position

-(Void) beginUpdates; // this parameter is used in pairs with the following method, indicating that a row is changed dynamically.

-(Void) endUpdates; // used in pairs with the preceding method, indicating that the end of a row is dynamically changed.

-(Void) insertSections :( NSIndexSet *) sections withRowAnimation :( UITableViewRowAnimation) animation; // insert a row dynamically

-(Void) deleteSections :( NSIndexSet *) sections withRowAnimation :( UITableViewRowAnimation) animation; // delete a group dynamically

-(Void) reloadSections :( NSIndexSet *) sections withRowAnimation :( UITableViewRowAnimation) animation; // refresh a group

-(Void) moveSection :( NSInteger) section toSection :( NSInteger) newSection; // move a group

-(Void) insertRowsAtIndexPaths :( NSArray <NSIndexPath *> *) indexPaths withRowAnimation :( UITableViewRowAnimation) animation; // insert multiple rows

-(Void) deleteRowsAtIndexPaths :( NSArray <NSIndexPath *> *) indexPaths withRowAnimation :( UITableViewRowAnimation) animation; // Delete multiple rows

-(Void) reloadRowsAtIndexPaths :( NSArray <NSIndexPath *> *) indexPaths withRowAnimation :( UITableViewRowAnimation) animation; // refresh multiple rows

-(Void) moveRowAtIndexPath :( NSIndexPath *) indexPath toIndexPath :( NSIndexPath *) newIndexPath; // move a row

-(Void) selectRowAtIndexPath :( nullable NSIndexPath *) indexPath animated :( BOOL) animated scrollPosition :( UITableViewScrollPosition) scrollPosition; // select a row to scroll to a specific position

-(Void) deselectRowAtIndexPath :( NSIndexPath *) indexPath animated :( BOOL) animated; // deselect

-(UITableViewCell *) dequeueReusableCellWithIdentifier :( NSString *) identifier; // you can specify the cell reuse identifier.

-(UITableViewCell *) dequeueReusableCellWithIdentifier :( NSString *) identifier forIndexPath :( NSIndexPath *) indexPath; // set the reuse identifier of some cells

-(UITableViewHeaderFooterView *) dequeueReusableHeaderFooterViewWithIdentifier :( NSString *) identifier; // set the reuse identifier of the header and tail views

-(Void) registerNib :( nullable UINib *) nib forCellReuseIdentifier :( NSString *) identifier; // register a cell with a reuse identifier through xib

-(Void) registerClass :( nullable Class) cellClass forCellReuseIdentifier :( NSString *) identifier; // register a cell with a reuse identifier through the Class

-(Void) registerNib :( nullable UINib *) nib forHeaderFooterViewReuseIdentifier :( NSString *) identifier; register the reused cell head and end views through xib

-(Void) registerClass :( nullable Class) aClass forHeaderFooterViewReuseIdentifier :( NSString *) identifier; register the header and tail view of the reused cell through the Class

Attachment:

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.