因此,我在這裏遇到了一些問題,我想我在這篇文章的標題中明確表達了自己的觀點。我想根據我在代碼中聲明的順序對UITableView
標題進行排序。我試過網上衝浪,但我找不到任何解決方案。如何根據聲明順序對UITableView頭文件進行排序
我覺得從這裏可以幫助。提前致謝!
編輯:這是我的代碼的表視圖內容
NSDictionary *temp = [[NSDictionary alloc]initWithObjectsAndKeys:accSettingsOpts, @"Account",notifSettingsOpts,@"Notifications",aboutOpts,@"About",logoutOpt,@"Sign Out",nil];
我想顯示由
-Account
-Notifications
-About
-Sign Out
排序表視圖,但它顯示爲
-About
-Account
-Notifications
-Sign Out
編輯:這是如何解決問題。
從提供的答案在我下面接受基礎,我修改了它作爲
@interface myClass()
NSArray *headerArr;
@end
在viewDidload
我加入
headerArr = [[NSArray alloc]initWithObjects:@"Account",@"Notifications",@"About",@"Sign Out", nil];
,最後...
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return [headerArr objectAtIndex:section];
}
謝謝爲幫助傢伙。我並不認爲這很簡單。
它幫助!非常感謝!我將我的標題數據存儲在一個數組中,並用它來顯示文本標題... +1,我接受了答案。 – caribbean