小编use*_*707的帖子

如何使用Swift在iOS 10中拨打电话?

我希望我的应用程序能够在单击按钮时调用某个数字.我试图谷歌它但是到目前为止似乎没有iOS 10(openURL已经消失).有人能为我举个例子吗?例如:

@IBAction func callPoliceButton(_ sender: UIButton) {
    // Call the local Police department
}
Run Code Online (Sandbox Code Playgroud)

phone-call ios swift swift3 ios10

68
推荐指数
6
解决办法
7万
查看次数

swift表视图没有填充

我在从数组中填充表格视图时遇到了一些麻烦.虽然我的数组不是空的(我尝试在控制台中打印它并且有我想要的数据),但tableView并没有填充我想要的东西,而是空的.我想知道我是否在这里做了任何错误导致这一点

这是我的代码:

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

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

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
   var cell = UITableViewCell()
    // display our ranked data
    cell.textLabel?.text = "\(tableData[indexPath.row])"
    return cell
}
Run Code Online (Sandbox Code Playgroud)

其中numberOfGamesPlayedRecently是一个int,而我的tableData是一个纪元时间数组

谢谢!

uitableview swift

1
推荐指数
1
解决办法
1471
查看次数

swift detailTextLabel没有显示出来

我已经检查了stackOverFlow的解决方案,但它似乎仍然没有为我的代码工作..我的detailTextLabel仍然没有显示:(

想知道我做错了什么,这是我的代码

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    var cell = UITableViewCell()
    // display our ranked data
    cell.textLabel?.text = "\(championListInGame[indexPath.row])"

    if let url = NSURL(string: "http://ddragon.leagueoflegends.com/cdn/img/champion/loading/\(championListInGame[indexPath.row])_0.jpg"){
        if let urlData = NSData(contentsOfURL: url){
            cell.imageView?.contentMode = UIViewContentMode.ScaleAspectFit
            cell.imageView?.image = UIImage(data: urlData)
        }
    }

    if victory[indexPath.row] == true {
        cell.backgroundColor = UIColor.blueColor()
        cell.detailTextLabel?.text = " "+"victory!"
    } else {
        cell.backgroundColor = UIColor.redColor()
        cell.detailTextLabel?.text = " "+"defeat!"
    }

    return cell
}
Run Code Online (Sandbox Code Playgroud)

然而,我的胜利和失败都出现在我的桌子中,颜色,图像和文字都像我想要的那样出现.

在旁注,有人可以教我如何选择婴儿蓝或婴儿红等颜色?默认的红色和蓝色对我的应用来说太强了:(

谢谢你的帮助!

colors tableviewcell swift

0
推荐指数
1
解决办法
2720
查看次数

标签 统计

swift ×3

colors ×1

ios ×1

ios10 ×1

phone-call ×1

swift3 ×1

tableviewcell ×1

uitableview ×1