我从上到下滚动时遇到问题,然后我的tableview可重复使用的单元格显示旧图像,直到新图像下载完成.
它应显示我的默认图像占位符,直到下载完成后下载新图像,然后将imageview从图像占位符更改为当前下载图像.我该怎么办 ?
抱歉英语不好.如果您需要任何信息,请告诉我们,谢谢
更新
TableViewcontroller:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ItemTableViewCell") as! ItemTableViewCell
let itemInfo = itemInfos[indexPath.row]
var image1 : UIImage?
var image2 : UIImage?
if let imgUrl1 = itemInfo.imageUrl {
image1 = ItemListViewController.imageCache.object(forKey: imgUrl1 as AnyObject) as? UIImage
}
if let imgUrl2 = itemInfo.cookerProfilePicUrl{
image2 = ItemListViewController.imageCache.object(forKey: imgUrl2 as AnyObject) as? UIImage
}
cell.configureCell(iteminfo: itemInfo, img1 : image1 ,img2 : image2)
return cell
}
Run Code Online (Sandbox Code Playgroud)
厦门国际银行:
func configureCell(iteminfo:ItemInfo …Run Code Online (Sandbox Code Playgroud) 我是新来的iOS 迅速和swrevealviewcontroller。我面临一个问题!在我的幻灯片菜单中(场景TableViewController,有两个蓝线绘制),在选中时,每行然后应打开粒子scene(视图控制器),但是不幸的是它没有打开。didselectRowAt当我从表中选择行但pushViewController不起作用时,没有错误和火灾。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let dvcStoryBordId = menuViewIds[(indexPath.row - 1 )]
let viewController = storyboard?.instantiateViewController(withIdentifier: dvcStoryBordId )
self.navigationController?.pushViewController(viewController!, animated: true)
}
Run Code Online (Sandbox Code Playgroud)
故事板
我想念什么吗?这是正确的方法吗?自。
更新:
self.navigationController是nil。还有其他选择吗?或没有导航
更新:
情节提要ID
menuViewIds = ["shareWithFriends","deliveryTracking", "controls", "support","myAccount"]
Run Code Online (Sandbox Code Playgroud)
运行时视图
我是新手Swift,我尝试了这个
不知道为什么此代码不起作用:
//start mehtod out of scope
lazy var locationManager: CLLocationManager! = {
let locationManager = CLLocationManager()
//configeration for user location access
//The delegate object to receive update events.
locationManager.delegate = self
//The receiver does its best to achieve the requested accuracy
//locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.distanceFilter = 10.0
//Requests permission to use location services while the app is in the foreground
locationManager.requestWhenInUseAuthorization()
//allow update notification when apps stay on background
locationManager.allowsBackgroundLocationUpdates = true
return locationManager
}()
Run Code Online (Sandbox Code Playgroud)
当我设置时它工作正常: …
我在ViewController哪里有两个,collectionView但我要一个isPagingEnabled用于单元格,另一个要collectionView 用于全帧宽度的花药3个项目。我怎样才能做到这一点 ?
用于分页的MenuCollectionView:完美运行
func setupMenuCollection(){
if let flowLayout = menuCollectionView?.collectionViewLayout as? UICollectionViewFlowLayout {
flowLayout.scrollDirection = .horizontal
flowLayout.minimumLineSpacing = 0
}
menuCollectionView?.backgroundColor = UIColor.white
menuCollectionView?.contentInset = UIEdgeInsetsMake(50, 0, 0, 0)
menuCollectionView?.scrollIndicatorInsets = UIEdgeInsetsMake(50, 0, 0, 0)
menuCollectionView?.isPagingEnabled = true
}
Run Code Online (Sandbox Code Playgroud)
它用于manubarCollectionView:它不起作用,因为这里没有else语句。
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
if manubarCollectionView == collectionView {
return CGSize(width: view.frame.width / 3, height: manubarCollectionView.frame.height)
}
}
Run Code Online (Sandbox Code Playgroud) 遵循这一行
lable2xValue.text = numberFormatter.string(from: value)
Run Code Online (Sandbox Code Playgroud)
首先是它抛出这个错误
无法将"Double"类型的值转换为预期的参数类型"NSNumber"
然后Xcode建议value替换为NSNumber
lable2xValue.text = numberFormatter.string(from: NSNumber(value))
Run Code Online (Sandbox Code Playgroud)
当我这样做,然后显示此错误
参数标签'(_ :)'与任何可用的重载都不匹配
这是我的完整代码
//computed property
var value2x : Double? {
if let value = value1x{
return (value * 2)
}
else{
return nil
}
}
//objerver
var value1x : Double? {
didSet{
updateLabel2xValue()
}
}
func updateLabel2xValue(){
if let value = value2x {
//lable2xValue.text = "\(value)"
//MARK:- ERORR Cannot convert value of type 'Double' to expected argument type 'NSNumber'
//lable2xValue.text = numberFormatter.string(from: value)
//MARK:- …Run Code Online (Sandbox Code Playgroud) 我花了很多时间..但我不知道为什么它不起作用..调用索引路径的单元格并正确设置值但单元格类我发现值为零..如果您需要任何信息,请告诉我。
在我的 collectionview 索引路径中
在 collectionview 单元格中
这是我的代码:
对于集合视图:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: menuBarItemDetailId, for: indexPath) as! MenuBarItemDetail
cell.shopCategory = "600"
print(cell.shopCategory)
return cell
}
Run Code Online (Sandbox Code Playgroud)
对于细胞:
class MenuBarItemDetail: UICollectionViewCell , UITableViewDataSource , UITableViewDelegate {
var shopCategory : String?
override init(frame: CGRect) {
super.init(frame: frame)
print("shopCategory :-> ...i am calling from cell :\(shopCategory)")
}
Run Code Online (Sandbox Code Playgroud)