小编jbm*_*223的帖子

Swift tableView.dequeueReusableCell从不返回Nil

这是我生成表格视图的Swift代码.我正在尝试设置带有详细标签的tableView.问题是永远不会调用以下代码.

if (cell == nil) {
            println("1")
            cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "CellSubtitle")
            //cell = tableViewCell
        }
Run Code Online (Sandbox Code Playgroud)

以下是该方法所需的代码:

    func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
    println("start TableViewCellForRowAtIndexPath")
    var cell: UITableViewCell! = tableView.dequeueReusableCellWithIdentifier("CellSubtitle", forIndexPath: indexPath) as UITableViewCell
    if (cell == nil) {
        println("1")
        cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "CellSubtitle")
        //cell = tableViewCell
    }

    cell.textLabel.text = instructions[indexPath.row].text
    println("2")
    //cell.detailTextLabel
    cell.detailTextLabel.text = "HI"
    println("3")
Run Code Online (Sandbox Code Playgroud)

以下是该方法的控制台输出:

start load
1
2
done load
start TableViewCellForRowAtIndexPath
2
fatal error: Can't unwrap Optional.None
(lldb) 
Run Code Online (Sandbox Code Playgroud)

如何初始化 …

uitableview ios swift

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

Swift UITableViewCell detailTextLabel.text抛出错误'致命错误:无法解包Optional.None'

这是我生成表格视图的Swift代码.我正在尝试设置带有详细标签的tableView.我相信问题的产生是因为

if (cell == nil) {
            println("1")
            cell = UITableViewCell(style: .Subtitle, reuseIdentifier: "CellSubtitle")
            //cell = tableViewCell
        }
Run Code Online (Sandbox Code Playgroud)

永远不会被调用,因此单元格永远不会被UITableViewCellStyle.Subtitle样式初始化.以下是该方法所需的代码:

    func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
    println("start TableViewCellForRowAtIndexPath")
    var cell: UITableViewCell! = tableView.dequeueReusableCellWithIdentifier("CellSubtitle") as UITableViewCell
    if (cell == nil) {
        println("1")
        cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "CellSubtitle")
        //cell = tableViewCell
    }

    cell.textLabel.text = instructions[indexPath.row].text
    println("2")
    //cell.detailTextLabel
    cell.detailTextLabel.text = "HI"
    println("3")
Run Code Online (Sandbox Code Playgroud)

以下是该方法的控制台输出:

start load
1
2
done load
start TableViewCellForRowAtIndexPath
2
fatal error: Can't unwrap Optional.None
(lldb) 
Run Code Online (Sandbox Code Playgroud)

如何初始化 …

uitableview ios swift

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

MYSQL PHP没有选择数据库 - 找不到错误

<?
require_once('etcore.php');
mysql_connect($dburl,$dbuser,$dbpass) or die(mysql_error()); 
mysql_select_db("rshost") or die(mysql_error());
$username=strtoupper(clean($_POST['username']));
$password=md5($_POST['password']);
$andover = mysql_query("SELECT * FROM users WHERE usernameupper='$username' AND password='$password'") or die(mysql_error().__LINE__);
$numberofthings = mysql_num_rows($andover) or die(mysql_error().__LINE__);
if ($numberofthings = 1) {
    $getit=mysql_fetch_array($andover) or die(mysql_error().__LINE__);
    $_SESSION['id'] = $getit['id'];
    header('Location: index.php');
}
else {
?>
<h1>Login:</h1>
<img src='http://media.idownloadblog.com/wp-content/uploads/2011/12/Warning.png' width="25" height="25" />
<strong style="color:#F03;">Incorrect Username and/or Password </strong><br>
<form method="POST" action="login.php">
Username: <input name="username" type="text" /><br />
Password: <input name="password" type="password" /><br />
<input name="submit" type="submit" value="Log In!" /><br />
</form>
<? …
Run Code Online (Sandbox Code Playgroud)

php mysql

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

相同的盐或不同的盐

这是我的问题:根据您的经验,为进行散列的 PHP 文件中存储的每个散列使用一个盐是否更安全,还是为每个散列对象使用不同的盐并将其与该对象一起存储在数据库中更好?

php mysql hash salt

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

PHP REGEX排除某些标签?

对于REGEX,我想知道如何清除所有输入的HTML标签,除了简单的标签,例如<a>, <b>, <i>, <pre>.我知道我可以使用这个正则表达式排除所有html字符集,但我不确定如何删除一些,并删除其他内容同时保留其中的内容.谢谢!

html php regex

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

标签 统计

php ×3

ios ×2

mysql ×2

swift ×2

uitableview ×2

hash ×1

html ×1

regex ×1

salt ×1