美文网首页
Swift 常用书写规范

Swift 常用书写规范

作者: fulen | 来源:发表于2017-11-27 13:29 被阅读67次
    声明tableView
     fileprivate var tableView : UITableView?;
     fileprivate var _supportRefresh:Bool = true;
     fileprivate var _supportLoadMore:Bool = true;
    
    var sections : Array<TableSection>;
    self.rowSelectedSignal = RACSubject();
    
    初始化tableView
    open func configure(_ tableView:UITableView)
        {
            self.tableView = tableView;
            self.tableView?.dataSource = self;
            self.tableView?.delegate = self;
        }
    // reload
    open func reload()
        {
            self.tableView?.reloadData();
        }
    // indexPath对应的row
    open func tableRowWithIndexPath(_ indexPath:IndexPath) -> TableRow
        {
            return self.sections[indexPath.section].rows[indexPath.row];
        }
    // 返回section
     open func numberOfSections(in tableView: UITableView) -> Int {
            return self.sections.count;
        }
     // 每个section中的行数
    open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
            return self.sections[section].rows.count;
        }
    

    遍历

    for c in 0...gridHeaders.count - 1 {
    // do something
            }
    

    常亮定义

        let navBarHeight:CGFloat = 45;
    

    相关文章

      网友评论

          本文标题:Swift 常用书写规范

          本文链接:https://www.haomeiwen.com/subject/omzrbxtx.html