注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

WA!Peter

广州天河, 香港火炭,深圳罗湖, 北京国贸

 
 
 

日志

 
 

iphone simple menu: EASY STARTUP  

2009-09-26 12:45:04|  分类: iphone |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
t1. Xcode - File - New Project 2. Choose iPhone OS(left), Navigation-based Application(right) 3. "Choose" (which is like OK) 4. Give the project a name, e.g. petertest 5. It generate a group of files, note: press "petertest" on left to show all files, press "Classes" under the petertest to show only the source code (.m and .h) 6. Select "RootViewController.m" (try not to customize the filename, for God sake) 7. find the following code: numberOfRowsInSection App-F to find // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1; // XXX change here, from 0 to 1 } 8. find the following code: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; // peter: some nil check here.... option // XXX add here: cell.textLabel.text = @"test1"; cell.detailTextLabel.text = @"detail1"; // this maybe optional? NSLog(@"DEBUG: indexPath.row = %d", indexPath.row); // useful to check this later return cell; } 9. Build it(App-B), Run it (App-Return) Summary: change the return value in 7. (e.g. return 3) and check the indexPath.row in 8. you may use the following code: NSString *str[] = { @"1111", @"2222", @"3333"}; cell.textLabel.text = str[indexPath.row]; // beware array out of bound Yes, it is hard coded now. do whatever you like for dynamic generation.
  评论这张
 
阅读(209)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017