0
我有一個表格視圖,其中一些單元格由2個標籤填充。
如果存在名爲「label1-label2-name」的mp3文件,則播放該文件。僅當文件存在時才顯示cell.button
NSArray *final;
NSString *element;
final = [NSArray arrayWithObjects: @"a", @"b", @"c", @"d", nil];
現在在我的cellForRowAtIndexPath
我試圖做同樣的,但如果該文件存在只是爲了顯示播放按鈕(按鈕最初是隱藏的)。
- (CustomCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
for (element in final) {
buttonA = [NSString stringWithFormat:@"%@-%@-AAA-%@", current[indexPath.row][0],current[indexPath.row][1], element];
fileA = [[NSBundle mainBundle] pathForResource:buttonA ofType:@"mp3"];
BOOL fileExistsA = [[NSFileManager defaultManager] fileExistsAtPath:fileA];
if (fileExistsA) {
cell.playA.hidden = false;
}
}
}
這裏發生的事情是,即使一個文件名爲 「LABEL1標籤-2-AAA-A」 的存在,如果文件 「LABEL1標籤-2-AAA-d」 不,播放按鈕將被隱藏。
如何顯示/隱藏特定單元格的播放?
是這樣的? button.A = [NSString stringWithFormat:@「%@ - %@ - AAA - %@」,current [indexPath.row] [ 0],當前[indexPath.row] [1],元素]; fileA = [[NSBundle mainBundle] pathForResource:buttonA ofType:@「mp3」]; BOOL fileExistsA = [[NSFileManager defaultManager] fileExistsAtPath:fileA]; }' – fabersky
對不起,我誤解了你的問題 - 我沒有意識到你循環'cellForRowAtIndexPath'中的'final'。我已經更新了我的答案。 –
那個伎倆!謝謝! – fabersky