ios - 屏幕旋转时ReloadData()

标签 ios swift reloaddata

当您转动我的设备屏幕时,我无法更新我的自定义 View 。

我试着这样做:

override func viewDidLoad() {
        super.viewDidLoad()


       var myCustomView = Customview()

       self.view.addsubview(myCustomView)
        }
    }

    override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) {

        // Reload Data here

        self.view.reloadData() // Incorrect

    }

但是让我出错:

方法“UIView”没有名为 reloadData 的方法

最佳答案

override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) {

    // Reload Data here

    self.view.reloadData() // Incorrect

}

UIView 不是 UITableView 它没有开箱即用的 reloadData 方法。

您可以手动实现此方法 -> 玩得开心 :)

关于ios - 屏幕旋转时ReloadData(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28046834/

相关文章:

ios - 图像未从 iOS 中的文件路径加载

ios - tableView reloadData 崩溃包括崩溃报告

ios - AVCaptureVideoPreviewLayer 未显示预览中心

ios - TableView Controller 不显示更新的核心数据值

swift - 在 UITableView 重新加载时从 SDWebImage 设置图像

ios - UICollection 的 IndexPath 到底是什么

ios - 如何检测何时点击谷歌地图 iOS Swift?

ios - Xcode Apple Pay - PKPaymentAuthorizationViewControllerDelegate 问题

ios - 覆盖 UILabel 字体会导致标签被截断

iphone - UITableView reloadData - cellForRowAtIndexPath 未触发