[問題] 把路徑的照片打開...

看板MacDev作者 (鹽です)時間14年前 (2011/03/23 17:30), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
如題 我把Document的路徑找了出來 path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); document = [path objectAtIndex:0]; fileList = (NSMutableArray*)[[[[NSFileManager defaultManager] contentsOfDirectoryAtPath:document error:nil] pathsMatchingExtensions:[NSArray arrayWithObjects:@"jpg",nil]]retain]; 把裡面的jpg全部列出來到TableView上 cell.textLabel.text = [fileList objectAtIndex:indexPath.row]; 結果我寫了一個藍色按鈕 想在按下之後新增一個View 並且把選到的照片用 imageView顯示出來 原本想說用 [tableView cellForRowAtIndexPath:indexPath].textLabel.text; 取到檔案名稱 並且寫出該張jpg的完整路徑 newpath = [document stringByAppendingFormat:@"/%@",[tableView cellForRowAtIndexPath:indexPath].textLabel.text]; 結果這句話好像有問題 而且我也不知道到底要怎麼做才可以讓新增的View的UIImageView讀入 這個路徑並把它顯示出來.... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 120.127.47.200

03/25 20:10, , 1F
不要用tableView:cellForRowAtIndexPath:讀取數據,那個是
03/25 20:10, 1F

03/25 20:11, , 2F
爲MVC的View之用的,應該從Model的部分取得數據。
03/25 20:11, 2F

03/25 23:21, , 3F
結果我最後還是用這個做出來了XD 是前面記憶體沒寫好
03/25 23:21, 3F
文章代碼(AID): #1DYRsa6G (MacDev)
文章代碼(AID): #1DYRsa6G (MacDev)