我在我的項目中創建了一個簡單的酒吧按鈕項目,但它在運行時未顯示。這是我聲明的方式在SWIFT中沒有顯示酒吧按鈕項目
@IBOutlet weak var songSelectionBar:UIBarButtonItem!
這是我的項目的屏幕截圖。我對swift相當陌生,所以我知道我正在做一些應該很簡單(或者不是)的事情。
下面是該項目更多的代碼。這個函數返回目錄的內容。我的理解是我應該使用tableview來顯示這個函數的輸出。任何人都可以給我一個例子,或告訴我如何做到這一點?謝謝
func getMusicFilesInDirectory() -> [String] {
//var wavFiles:[String]
// We need just to get the documents folder url
let documentsUrl = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).first!
// now lets get the directory contents (including folders)
do {
let directoryContents = try NSFileManager.defaultManager().contentsOfDirectoryAtURL(documentsUrl, includingPropertiesForKeys: nil, options: NSDirectoryEnumerationOptions())
print(directoryContents)
} catch let error as NSError {
print(error.localizedDescription)
}
// now filter the directory to extract only Wav Files
do {
let directoryUrls = try NSFileManager.defaultManager().contentsOfDirectoryAtURL(documentsUrl, includingPropertiesForKeys: nil, options: NSDirectoryEnumerationOptions())
print(directoryUrls)
let wavFilesDir = directoryUrls.filter(){ $0.pathExtension! == "wav" }.map{ $0.lastPathComponent! }
wavFiles = ["Wav Music Files:\n" + wavFilesDir.description]
} catch let error as NSError {
print(error.localizedDescription)
}
return wavFiles
}
是一個工具欄還是標籤欄? –
@ Mr.T我正在嘗試創建一個不存在於swift中的下拉菜單。所以讀完後我被告知使用Bar按鈕。也許我應該使用不同的對象。不確定從一種語言轉到另一種語言時,這些東西會變得混亂。 – Sophman