Uirefreshcontrol---Controls for refreshing uitableview, etc. in iOS

Source: Internet
Author: User
Tags uikit

In iOS development, it is often necessary to add the UITableView drop-down refresh feature, which can be easily implemented with Uirefreshcontrol.

Uirefreshcontrol

Below is the Uirefreshcontrol's header file.

ImportFoundationImportUIKit////UIRefreshControl.h//UIKit////Copyright 2012-2014 Apple Inc. All rights reserved.//@availability (IOS, introduced=6.0) class Uirefreshcontrol:uicontrol {/* The designated initializer * This Initializes a uirefreshcontrol with a default height and width.     * Once assigned to a Uitableviewcontroller, the frame of the control is managed automatically.     * When a user had Pulled-to-refresh, the Uirefreshcontrol fires its Uicontroleventvaluechanged event. */Init ()varRefreshing:bool {Get}vartintcolor:uicolor!varAttributedtitle:nsattributedstring?//May is used to indicate to the Refreshcontrol, the external event has initiated the Refresh action@availability (IOS, introduced=6.0)funcBeginrefreshing ()//must be explicitly called when the refreshing have completed@availability (IOS, introduced=6.0)funcEndrefreshing ()}

It can be seen that the invocation method provided is simple, init () is necessary to create the control, followed by the two methods of Beginrefreshing () and endrefreshing () to control the refresh.

Working with instances

Take UITableView refresh as an example, the use of Uirefreshcontrol is divided into the following steps:
1. Initialize a Uirefreshcontrol object.
2. Add the method called when refreshing, here is the Refreshdatasource () method.
3. Add the Uirefreshcontrol object to the TableView.
Then, drop down the device screen to see the effect.

var refreshctl = Uirefreshcontrol () var httpctl:httpcontroller = Httpcontroller ()//outlets @IBOutlet weak Var    tableview:uitableview! Override Func Viewdidload () {Super. Viewdidload()//Do any additional setup after loading the view, typically from a nib. Httpctl. Delegate= Self Refreshctl. Attributedtitle= Nsattributedstring (string:"Drop-down refresh") Refreshctl. AddTarget(Self, Action:"Refreshdatasource", forcontrolevents:uicontrolevents. ValueChanged) TableView. Addsubview(REFRESHCTL) Refreshdatasource ()} func Refreshdatasource () {Refreshctl. beginrefreshing() Httpctl. Getdataviansurlconnection("Http://0.0.0.0/dataapi") Refreshctl. endrefreshing()    }

Uirefreshcontrol---Controls for refreshing uitableview, etc. in iOS

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.