Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 没有附加值_Ios_Swift_Arraylist_Tableview - Fatal编程技术网

Ios 没有附加值

Ios 没有附加值,ios,swift,arraylist,tableview,Ios,Swift,Arraylist,Tableview,这是viewController import UIKit class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource { var array = [Product]() @IBOutlet weak var tableview: UITableView! override func viewDidLoad() {

这是viewController

    import UIKit

class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
    

    var array = [Product]()
    
    
    @IBOutlet weak var tableview: UITableView!
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.tableview.delegate = self
        self.tableview.dataSource = self

        array.append(Product.init(image: UIImage(named: "a1")!))
        array.append(Product.init(image: UIImage(named: "a2")!))
        array.append(Product.init(image: UIImage(named: "a3")!))
        // Do any additional setup after loading the view.
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        array.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! TableViewCell
        
        cell.imageview.image = array[indexPath.row].image
        
        return cell
    }

}
这是tableviewcell

import UIKit

class TableViewCell: UITableViewCell {

    @IBOutlet weak var imageview: UIImageView!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
这是一节课

我正在使用类似arraylist的类创建一个tableview我在运行应用程序时执行了以下代码它将崩溃并获得线程1:致命错误:在展开可选值时意外发现nil此错误意味着值为null,因此我想修复如何使用存储路径()修复值不追加的原因

缩略图}“width=“100”height=“100”/
如果将存储路径链接到公共路径

php artisan存储:链接 缩略图)}}“width=“100”height=“100”/>
Tableview id丢失,现在添加工作正常

您的文件存储在存储文件夹中的何处?请不要通过破坏您的帖子为其他人做更多工作。通过在Stack Exchange网络上发布,您已授予Stack Exchange在下不可撤销的权利,以分发该内容(即,无论您未来的选择如何)。根据堆栈交换策略,帖子的非破坏版本是分发的版本。因此,任何故意破坏行为都将恢复原状。如果您想了解有关删除帖子的更多信息,请参阅:
import UIKit

class Product
{
    var image: UIImage
    
    init(image: UIImage) {
        
        self.image = image
    }
}
<img src="{{storage_path().'app/public/images/'.$category->thumbnail}}" width="100" height="100" />
php artisan storage:link

<img src="{{asset('storage/images/'.$category->thumbnail)}}" width="100" height="100" />