- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个自定义表格 View ,当我运行该应用程序时,它显示为空白,就像它尚未加载一样,但是当我将手机倾斜到横向模式时,条目出现了,这对我来说真的没有意义。有什么建议吗?
编辑:这是我的代码
import UIKit
import Alamofire
import ObjectMapper
class LotteryTableViewController: UITableViewController {
let lotteryMachine = LotteryMachine()
var currentStandings: [Team] = []
var draftStandings: [Team] = []
override func viewDidLoad() {
super.viewDidLoad()
let headers = [
"User-agent": "LotteryMachine/1.0 (nilayneeranjun24@gmail.com)",
]
Alamofire.request(.GET, "https://erikberg.com/nba/standings.json",headers: headers)
.responseJSON { response in
let parentJson = Mapper<Standings>().map(response.2.value)
let standingsArray: [Team] = parentJson!.standing!
self.currentStandings=standingsArray
self.draftStandings=self.lotteryMachine.setPossibleCombinations(standingsArray)
self.draftStandings=self.lotteryMachine.setDraftPositions(self.draftStandings)
print (self.draftStandings.toJSON())
}
}
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return draftStandings.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier = "LotteryTableViewCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! LotteryTableViewCell
let position = self.draftStandings[indexPath.row].draftingPosition!
let teamName = self.draftStandings[indexPath.row].lastName!
let record = String(self.draftStandings[indexPath.row].won!) + "-" + String(self.draftStandings[indexPath.row].lost!)
let player = "Ben Simmons"
cell.position.text = String(position)
cell.teamName.text = teamName
cell.record.text = String(record)
cell.player.text = player
cell.teamLogo.image = UIImage(named: "lakers")
// Configure the cell...
return cell
}
/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
} else if editingStyle == .Insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
最佳答案
Alamofire.request
本质上是异步的。因此,当表格首次加载时,请求仍在执行,您的 draftStandings
没有任何数据。当您旋转时,表格会重新加载,到那时 draftStandings
确实已经有表格显示的一些数据。
尝试在请求响应中设置 draftStandings
后添加 tableView.reloadData()
。
关于ios - 仅当我将手机置于横向模式时才会加载表格 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36347579/
即使我的设备旋转(纵向->横向->纵向),我也需要始终以横向模式录制视频。 取角度很简单,我用的是hyroscope。我的问题是总是横向录制视频。需要任何建议。 我正在使用 AVCaptureSess
我正在 iPad(1,2) 以及 Samsung Tab 2 上测试我的网络应用程序。我有不同的 CSS(外部)集可应用于 iPad 上的横向/纵向模式和选项卡 2 上的横向/纵向模式。 但我无法为
我正在将Snappy Bundle和Symfony 2.1一起使用。 我有一些问题未在此捆绑包的文档中找到: 如何设置方向? 有没有显示页码的方法? 这是我的捆绑包的config.yml: knp_s
我一直在寻找这个问题的答案,但找不到任何答案。显然,iPhone SDK 3.0 使得 UIImagePickerController 可以以横向模式显示成为可能 - 但我没有找到任何允许这样做的方法
我有 1 个 Storyboard,我在 Swift 3 中的 Xcode 8 上使用带有大小类的自动布局。 我有这个当前的肖像 View : 目前,这是 1 个带有标签的垂直堆栈 View 。 在横
我正为这个而焦头烂额。基本上,我需要我的菜单根据菜单的内容水平放置一个容器。所以,我知道 table 和 table-cell 属性可以做到这一点。但是,当我将其与 Superfish Menu 结合
我努力做到这一点: 但我无法正确获取第三列和翻转的标题。 我现在是这样的: 最佳答案 该解决方案适用于 IE9、Chrome、Firefox、Safari 和 Opera,不需要 JavaScrip
我想要一个水平方向的 WPF DataGrid,有人知道解决方案吗? 最佳答案 我之前已经这样做了,因为我们希望能够对 DataGrid 和 PropertyGrid 使用相同的控件。很多事情都必须改
我正在开发一个适用于智能手机的网站版本,在处理智能手机横向方向的媒体查询时遇到了一个小问题。对于纵向,我正在使用以下媒体查询并且它工作得很好: @media only screen and (max-
如何让“AVCaptureVideoPreviewLayer”在横向方向上正确显示?它在纵向模式下工作正常但不旋转,并且当父 View Controller 处于横向模式时显示旋转的相机捕获。 最佳答
这个问题在这里已经有了答案: Force "portrait" orientation mode (12 个回答) 关闭2年前。 我的第一款 Android 游戏即将完成,但我遇到了一个非常简单的问题
我的数据在其中一个字段中具有嵌套映射。例如,数据位于名为“customers”的表中,如下所示: 姓名:比尔·琼斯 地址:{"billing":{"street":"123 Main", "city"
我正在横向模式下运行应用程序。我需要注意什么才能使拍摄的屏幕截图也处于横向模式。 我在 iPhone 应用程序中使用以下代码,底部有标签栏并拍摄屏幕截图,但它始终仅处于纵向模式。为什么? UIWind
谁能举例说明如何将单点触控应用程序的 View 从纵向旋转为横向,反之亦然? 最佳答案 如果您在 Interface Builder 中设置 ui 元素的几何形状,请确保在 Size Inspecto
我正在使用简单的 MPMoviePlayerController。在纵向模式下,它嵌入到我的布局中。当我旋转我的设备时,我希望它全屏显示。在全屏模式下,有一个完成按钮,但它唯一的作用就是暂停视频。当点
我正在尝试读取 JSON 模式,但似乎无法弄清楚如何将所有先前对象等输出到层次结构中。 这是JSON响应方案 { "Shopping": { "Orders": { "OrderInfo": {
我想在我的布局中包含一个 SlidingDrawer,但我会将它放在布局的侧面。所以开口是从左到右,而不是从下往上。这怎么办? 最佳答案 this link可能会帮助您创建水平滑动抽屉。如果您正在使用
就在我以为我已经解决了所有问题时..我遇到了这个问题。 场景。 我有一个简单的 tableView。并在导航项的 titleView 中带有搜索栏。 SearchBar 通过 View Control
我有一个带有 MGSplitView 的应用程序,其中包含表格 View 和 UIWebView,该应用程序固定为横向。 Web View 有一个附加到 Web View 的 UITapGesture
我有一部 iPhone,我正在添加横向支持。之前只是肖像。 当键盘显示时,我无法将文本字段移开。 我使用的解决方案与记录在案的 Apple 解决方案非常相似 here . 该解决方案在纵向模式下工作正
我是一名优秀的程序员,十分优秀!