Song list and channel list

Source: Internet
Author: User

Last time we implemented a basic interface for a music player, now we add songs and a list of channels to the player:

  

Implementing the list functionality is essentially configuring the UITableView control, which configures the UITableView to inherit the data source protocol and the two Protocol of the delegation Protocol:

Drag lines first to create TableView properties and inherit two protocols:

  

There are two methods in the data source protocol that must be implemented:

  

Then set the data source and proxy for the table:

  

Three simple steps, the song list is finished! ~

  

Next is the channel list.

The UI of the channel list is as follows, the configuration method is the same as above, it is worth mentioning that you can also directly bind the data source and the delegate with the Drag line method:

 

Create a new class as the controller for this view, with the following code:

Import UIKit

Class Channelcontroller:uiviewcontroller {
Channel TableView
@IBOutlet weak var tv:uitableview!

Override Func Viewdidload () {
Super.viewdidload ()

Do any additional setup after loading the view.
}

Override Func didreceivememorywarning () {
Super.didreceivememorywarning ()
Dispose of any resources the can be recreated.
}

Func TableView (Tableview:uitableview, Numberofrowsinsection section:int), int{
Return 8
}

Func TableView (Tableview:uitableview, Cellforrowatindexpath indexpath:nsindexpath), uitableviewcell{
Let cell = Tv.dequeuereusablecellwithidentifier ("channel") as! UITableViewCell
Cell.textlabel?. Text = "Channel: \ (Indexpath.row)"
return cell
}
}

Once completed, a simple channel list is implemented:

  

This basic UI is done, and the next time you'll be explaining how to get data from the web and present it in our app.

Song list and channel list

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.