Pourquoi à l'échelle pour remplir donnent une image plus grande que UIImageVIew taille? (l'utilisation de swift)

Je suis en train de montrer une liste de nom de lieu, dont c'est la photo à l'aide de PFQueryTableViewController. Il est inclus dans ParseUI SDK de parse.com

J'ai réussi à afficher l'image. Malheureusement, lorsque je change la UIImageView mode à l'Aspect de remplissage, l'image est devenue plus grande qu'elle ne devrait l'être.

voici les photos:

https://dl.dropboxusercontent.com/u/86529526/pic_normal.png
https://dl.dropboxusercontent.com/u/86529526/pic_error.png

dans pic_normal, vous verrez deux cellules, avec deux image normale.
dans pic_error, vous aurez la deuxième cellule était recouverte par la première cellule de l'image.

quelqu'un peut-il m'aider à résoudre ce problème? J'ai aussi mis mon code entier ici :

import UIKit
class TableViewController: PFQueryTableViewController, UISearchBarDelegate {
@IBOutlet var searchBar: UISearchBar!
//Initialise the PFQueryTable tableview
    override init(style: UITableViewStyle, className: String!) {
super.init(style: style, className: className)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
//Configure the PFQueryTableView
        self.pullToRefreshEnabled = true
self.paginationEnabled = false
}
//Define the query that will provide the data for the table view
    override func queryForTable() -> PFQuery {
//Start the query object
        var query = PFQuery(className: "Places")
//query with pointer
        query.includeKey("mainPhoto")
//Add a where clause if there is a search criteria
        if searchBar.text != "" {
query.whereKey("name", containsString: searchBar.text)
}
//Order the results
        query.orderByAscending("name")
//Return the qwuery object
        return query
}
//override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject) -> PFTableViewCell? {
var cell = tableView.dequeueReusableCellWithIdentifier("CustomCell") as! CustomTableViewCell!
if cell == nil {
cell = CustomTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "CustomCell")
}
//Extract values from the PFObject to display in the table cell
        if let name = object["name"] as? String{
cell.name.text = name
}
//display initial image
        var initialThumbnail = UIImage(named: "question")
cell.photo.image = initialThumbnail
//extract image from pointer
        if let pointer = object["mainPhoto"] as? PFObject {
cell.detail.text = pointer["photoTitle"] as? String!
if let thumbnail = pointer["photo"] as? PFFile {
cell.photo.file = thumbnail
cell.photo.loadInBackground()
}
}
cell.sendSubviewToBack(cell.photo)
//return the cell
        return cell
}
//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].
        var detailScene = segue.destinationViewController as! DetailViewController
//Pass the selected object to the destination view controller.
        if let indexPath = self.tableView.indexPathForSelectedRow() {
let row = Int(indexPath.row)
detailScene.currentObject = objects[row] as? PFObject
}
}
override func viewDidLoad(){
super.viewDidLoad()
let tapGesture = UITapGestureRecognizer(target:self, action:Selector("hideKeyboard"))
tapGesture.cancelsTouchesInView = true
tableView.addGestureRecognizer(tapGesture)
}
func hideKeyboard(){
tableView.endEditing(true)
}
override func viewDidAppear(animated: Bool) {
//Refresh the table to ensure any data changes are displayed
        tableView.reloadData()
//Delegate the search bar to this table view class
        searchBar.delegate = self
}
func searchBarTextDidEndEditing(searchBar: UISearchBar) {
//Dismiss the keyboard
        searchBar.resignFirstResponder()
//Force reload of table data
        self.loadObjects()
}
func searchBarSearchButtonClicked(searchBar: UISearchBar) {
//Dismiss the keyboard
        searchBar.resignFirstResponder()
//Force reload of table data
        self.loadObjects()
}
func searchBarCancelButtonClicked(searchBar: UISearchBar) {
//Clear any search criteria
        searchBar.text = ""
//Dismiss the keyboard
        searchBar.resignFirstResponder()
//Force reload of table data
        self.loadObjects()
}
}
  • faire UIImageView mode à l'Aspect Ajustement
  • Je veux remplir le UIImageVIew, mais aussi de garder le ratio d'aspect.
  • reportez-vous à cette réponse vous savez la différence entre l'aspect de remplir et de l'aspect ajustement stackoverflow.com/questions/4895272/...
  • Cette réponse m'a aidé lorsque tous les UIViewContentModes ne pourrais pas. - stackoverflow.com/a/35685883/8694980
InformationsquelleAutor Gibran | 2015-05-06