我想获得一个在线图像的尺寸,以了解我想要放置的网格的高度。 我试图将它放在一个临时网格中以获得“图像”(UI元素)的“ActualHeight”,但它是“NaN”(或0)。
我通常使用类似的东西(对于Win32 .NET软件),但我无法在UWP中使用它:
import UIKit
import CoreData
class RoomTableViewController: UITableViewController, NSFetchedResultsControllerDelegate {
/
let moc = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
/
var frc : NSFetchedResultsController = NSFetchedResultsController()
override func viewDidLoad() {
super.viewDidLoad()
/
frc = getFRC()
frc.delegate = self
/
fetch(frc)
/
/
/
/
}
/
func fetch(frcToFetch: NSFetchedResultsController) {
do {
try frcToFetch.performFetch()
} catch {
let fetchError = error as NSError
print("\(fetchError), \(fetchError.userInfo)")
}
}
func getFRC() -> NSFetchedResultsController {
frc = NSFetchedResultsController(fetchRequest: fetchRequest(), managedObjectContext: moc, sectionNameKeyPath: nil, cacheName: nil)
return frc
}
func fetchRequest() -> NSFetchRequest {
let fetchRequest = NSFetchRequest(entityName: "Rooms")
let sortDescriptor = NSSortDescriptor(key: "roomName", ascending: true)
fetchRequest.sortDescriptors = [sortDescriptor]
return fetchRequest
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
/
}
func controllerDidChangeContent(controller: NSFetchedResultsController) {
tableView.reloadData()
}
/
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
/
let numberOfSections = frc.sections?.count
return numberOfSections!
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
/
/
let numberOfRowsInSection = frc.sections?[section].numberOfObjects
return numberOfRowsInSection! }
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
let room = frc.objectAtIndexPath(indexPath) as! Rooms
print(room)
cell.textLabel!.text = "\(room.roomName!)"
return cell
}
/
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
/
return true
}
/
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
/
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
} else if editingStyle == .Insert {
/
}
}
}
VB.Net或C#都可以使用。