麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

swift-UITableView的基本使用

2019-11-14 18:04:19
字體:
供稿:網(wǎng)友

廢話不多說了,直接貼我今天寫的代碼吧:如果新手有什么不懂的,可以發(fā)我郵箱。

//

//  singleInfo.swift            個(gè)人信息

//  Housekeeper

//

//  Created by 盧洋 on 15/10/27.

//  Copyright © 2015 奈文摩爾. All rights reserved.

//

 

import Foundation

import UIKit

class singleInfo:UIViewController,UITableViewDataSource,UITableViewDelegate{

    var dataTable:UITableView!;                                             //數(shù)據(jù)表格

    var itemString=["昵稱","賬號(hào)","性別","地區(qū)","我的愛車"]

 //當(dāng)前屏幕對(duì)象

  var screenObject=UIScreen.mainScreen().bounds;

    

    //頁(yè)面初始化

    override func viewDidLoad() {

        super.viewDidLoad();

        initView();

    }

    /**

    UI 初始化

    */

    func initView(){

        self.title="我的資料";

        self.view.backgroundColor=UIColor.linghtGreyBg();

        creatTable();

    }

    /**

    我的資料表格初始化

    */

    func creatTable(){

        let dataTableW:CGFloat=screenObject.width;   

        let dataTableH:CGFloat=screenObject.height;

        let dataTableX:CGFloat=0;

        let dataTableY:CGFloat=0;

        dataTable=UITableView(frame: CGRectMake(dataTableX, dataTableY, dataTableW, dataTableH),style:UITableViewStyle.Grouped);

        dataTable.delegate=self;      //實(shí)現(xiàn)代理

        dataTable.dataSource=self;    //實(shí)現(xiàn)數(shù)據(jù)源

        self.view.addSubview(dataTable);

    }

    //1.1默認(rèn)返回一組

    func numberOfSectionsInTableView(tableView: UITableView) -> Int {

        return 2;

    }

    

    // 1.2 返回行數(shù)

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        if(section == 0){

            return 1;

        }else{

            return 5;

        }

    }

    

    //1.3 返回行高

    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat{

        

        if(indexPath.section == 0){

            return 80;

        }else{

            return 55;

        

        }

    }

    

    //1.4每組的頭部高度

    func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {

        return 10;

    }

    

    //1.5每組的底部高度

   func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {

        return 1;

    }

    //1.6 返回?cái)?shù)據(jù)源

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

        let identifier="identtifier";

        var cell=tableView.dequeueReusableCellWithIdentifier(identifier);

        if(cell == nil){

            cell=UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: identifier);

        }

        

        if(indexPath.section == 0){

            cell?.textLabel?.text="頭像";

        }else{

            cell?.textLabel?.text=itemString[indexPath.row];

        }

        cell?.accessoryType=UITableViewCellAccessoryType.DisclosureIndicator;

        return cell!;

    }

//1.7 表格點(diǎn)擊事件

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

        //取消選中的樣式

        tableView.deselectRowAtIndexPath(indexPath, animated: true);

   //獲取點(diǎn)擊的行索引

        if(indexPath.row == 0){

            let pushSingleInfo=singleInfo();

            pushSingleInfo.hidesBottomBarWhenPushed=true;    //隱藏導(dǎo)航欄

            self.navigationController?.pushViewController(pushSingleInfo, animated: true);

        }

    }

 

    //內(nèi)存警告

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning();

        PRint("個(gè)人信息內(nèi)存警告");

    }

}

效果圖如下:


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 久久久久久精 | 欧美成人精品欧美一级乱黄 | 一本色道久久综合狠狠躁篇适合什么人看 | 黄色免费在线网址 | 九九热免费视频在线观看 | 手机国产乱子伦精品视频 | 日本中文一级片 | 香蕉国产精品 | 久久金品| 在线播放免费播放av片 | 午夜精品久久久久久久久久久久久蜜桃 | 久久国产精品网 | 91久久夜色精品国产网站 | 国产一国产一级毛片视频 | 久久sp | 精品国产乱码久久久久久久 | 国产欧美日韩视频在线观看 | 久久国产精品久久久久久 | 成人午夜视屏 | 91羞羞 | 亚洲一区二区三区精品在线观看 | 久久性生活免费视频 | 黄色免费在线网址 | 亚洲一级片在线观看 | 91av资源在线 | 美国av片在线观看 | 成人免费毛片一 | 中国国语毛片免费观看视频 | 国产精品午夜一区 | 女人裸体让男人桶全过程 | 黄色特级视频 | 青草久久久久 | 国产羞羞视频免费在线观看 | 欧美成年性h版影视中文字幕 | 免费观看欧美一级片 | 国产精品刺激对白麻豆99 | 日本aaaa片毛片免费观看视频 | 国产亚洲综合一区二区 | 黄色av片三级三级三级免费看 | 1024亚洲天堂 | av免费在线播放 |