我在Xcode上遇到错误,我需要修复size类。在我这样做之后,我回到了我的一个表视图,并在tableview中的第一个原型单元格上方添加了空白区域。我怎么能摆脱这个空间?我在下面添加了这张图片,以便更好地描述我的意思。
https://www.dropbox.com/s/7ebxipb0r2jakav/TableViewProblem.png?dl=0
@IBOutlet var schoolTable: UITableView!
var namesArray = [String]()
var locationsArray = [String]()
var currentUser = PFUser.currentUser()
var theSchoolName: String = "None Selected"
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(animated: Bool) {
namesArray.removeAll(keepCapacity: false)
locationsArray.removeAll(keepCapacity: false)
var query = PFQuery(className: "Schools")
query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
if let objects = query.findObjects() as? [PFObject] {
for object in objects {
self.namesArray.append(object.valueForKey("schoolName") as! String)
self.locationsArray.append(object.valueForKey("schoolLocation") as! String)
self.schoolTable.reloadData()
}
}
} else {
println("Oops, it didn't work...")
}
}
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.namesArray.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:ChangeSchoolListTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell") as! ChangeSchoolListTableViewCell
if namesArray.count > 0 {
cell.nameLabel.text = namesArray[indexPath.row]
cell.locationLabel.text = locationsArray[indexPath.row]
}
return cell
}
答案 0 :(得分:1)