TableView Display list content data in iOS development (version Storyboard)
Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="color: #ff0000; font-size: 16px;">This is the first time to blog this kind of things, and the same as Rookie-level self-learning ios, If there are some incorrect hope you correct, thank you ...</span></p></p><p><p><span style="font-size: 16px;"></span></p></p><p><p><span style="color: #ff6600; font-size: 16px;">First write a lesson that everyone will use when Self-study-list display, perhaps you do not think this is a problem, it is because you are intelligent, just the school hours is disturbing to me, deliberately write;</span></p></p><p><p></p></p><p><p><strong>First Step: Create a project Ios--single view application</strong></p></p><p><p><strong>--"Product Name:tableviewdemo</strong></p></p><p><p><strong>Language:objective-c</strong></p></p><p><p><strong>devices:iphone,</strong></p></p><p><p><strong>Click next, Select your folder, Create</strong></p></p><p><p><strong>--click on main.storyboard, (we'll Use the view controller that comes with the build Project)</strong></p></p><p><p><strong>Locate the UITableView control in the control bar and drag it to the attempt controller (you can overwrite it all or cover a portion of the Area)</strong></p></p><p><p><strong></strong></p></p><p><p></p></p><p><p><strong>Step Two: Set the TableView DataSource and delegate</strong></p></p><p><p><strong>Click on the top of the first yellow flag, then click on the top of the last button, such as the interface;</strong></p></p><p><p><strong></strong></p></p><p><p></p></p><p><p><strong>--"in The referencing outlets column, drag a line from the hollow circle to the UITableView control we just covered; pop datasource and delegate; select delegate;</strong></p></p><p><p><strong>--"repeat the last process of drag and drop, and choose datasource;"</strong></p></p><p><p></p></p><p><p><strong>Step three: Code Implementation display</strong></p></p><p><p><strong>--"open ViewController.h File</strong></p></p><pre><pre>#import <UIKit/UIKit.h> @interface viewcontroller:uiviewcontroller<uitableviewdelegate, Uitableviewdatasource> @end</pre></pre><p><p></p></p><p><p><strong></strong></p></p><p><p><strong>--"open the viewcontroller.m file and implement the TableView proxy method</strong></p></p><p><p><strong>(1) define the global variable Arraydata for the content we want to display on the list text</strong></p></p><p><p><strong>(2) in Viewdidload (), the array variable is initialized;</strong></p></p><p><p><strong>(3) Implement Proxy method</strong></p></p><span class="cnblogs_code_copy"><span class="cnblogs_code_copy"></span></span><pre>#import "ViewController.h" @interface viewcontroller () @property (nonatomic, Strong) nsarray *arraydata;@ End@implementation viewcontroller@synthesize arraydata;-(void) viewdidload {[super viewdidload]; Additional setup after loading the view, typically from a nib. Arraydata = [nsarray arraywithobjects:@ "wang Xiao hu", @ "guo two cows", @ "song Xiao liu", @ "geng old three", @ "cao da general", nil];} #pragma mark-delegate method-(nsinteger) numberofsectionsintableview: (uitableview *) tableview{return 1;} -(nsinteger) tableView: (uitableview *) tableView numberofrowsinsection: (nsinteger) section{return arraydata.count;} -(uitableviewcell *) tableView: (uitableview *) tableView cellforrowatindexpath: (nsindexpath *) indexpath{static NSString *indentifier = @ "cell"; UITableViewCell *cell = [tableView dequeuereusablecellwithidentifier:indentifier]; If (!cell) {cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:indentifier ]; } Cell.textLabel.text = [arraydata objectAtIndex:indexPath.row]; Return cell;} -(void) didreceivememorywarning {[super didreceivememorywarning]; Dispose of any resources the can be recreated.} @end</pre><span class="cnblogs_code_copy"><span class="cnblogs_code_copy"></span></span><p><p></p></p><p><p><strong>Click to Run: you can start with the following effect</strong></p></p><p><p><strong></strong></p></p><p><p></p></p><p><p>TableView Display list content data in iOS development (version Storyboard)</p></p></span>
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