创建一个 plist 来存储单词及其定义的最佳方法是什么,然后用于填充按字母顺序分成多个部分的 TableView ,每个单元格通向一个详细 View 。 我连接了我的表和 plist,并了解如何通过准备 segue 获得详细 View 。我的问题是 plist 布局,然后将其用于章节标题并让单词与正确的字母相对应。
最近两天在 google 上多次搜索超过 30 页。我看过谓词之类的术语,但我很困惑。
我不希望有人编写代码,但步骤列表将是救命稻草。我担心不对表格进行分区会导致糟糕的使用体验。
最佳答案
只需按照下面的操作即可。
1.创建PList并赋予相关名称
2.做以下事情
Key Type Value
Root Array (2 items)
->Expend the arrow of root (to below-down) direction
Item 0 Dictionary (2 items)
->Expend the arrow of Item 0 (to below-down) direction->Click + and add the below things
Name String First Section Name
List Array (1 items)
->Expend the arrow of List (to below-down) direction->Just Click + for adding item 0
Item 0 Dictionary (6 items)
->Expend the arrow of Item 0 (to below-down) direction ->Click + and the below things
Name String EnterName
Value String
Key String Name
UIType String TextField
InputType String Text
Mandatory Boolean YES
Then if you click the root there is +.Just click the + and you can see the Item 1
Key Type Value
Root Array (2 items)
Item 0 Dictionary (2 items)
Item 1 Dictionary (2 items)
->Expend the arrow of root (to below-down) direction
Item 1 Dictionary (2 items)
->Expend the arrow of Item 1 (to below-down) direction-Click + and add the below things
Name String Second Section Name
List Array (1 items)
->Expend the arrow of List (to below-down) direction-Just Click + for adding item 0
Item 0 Dictionary (6 items)
->Expend the arrow of Item 0 (to below-down) direction-Click + and the below things
Name String Enter Age
Value String
Key String Age
UIType String TextField
InputType String Text
Mandatory Boolean YES
3.然后创建NSObject类名作为PList。
在 .h 中
#import <Foundation/Foundation.h>
@interface PList : NSObject
+ (NSMutableArray *)arrayPlistInit:(NSString *)plistName;
@end
.m
+(NSMutableArray *)arrayPlistInit:(NSString *)plistName
{
NSString *stringPath = [[NSBundle mainBundle]pathForResource:plistName ofType:@"plist"];
NSMutableArray *arrayPlist = [NSMutableArray arrayWithContentsOfFile:stringPath];
return arrayPlist;
}
4.在viewDidLoad中
arrayTable = [PList arrayPlistInit:stringPlistName];
5.然后查看ForHeaderInSection
1.Create the Custom Label and View(see the below the Coding in viewForHeaderInSection)
UILabel *labelSection;
UIView *viewSection = [[UIView alloc]init];
viewSection.frame = CGRectMake(0, 0, tableviewCreate.frame.size.width, 20);
labelSection = [[UILabel alloc]init];
labelSection.textAlignment = NSTextAlignmentLeft;
labelSection.frame = CGRectMake(10, 5, tableviewCreate.frame.size.width, 20);
[labelSection setBackgroundColor:[UIColor clearColor]];
[labelSection setFont:[UIFont boldSystemFontOfSize:15]];
NSString *name = [[arrayTable objectAtIndex:section] objectForKey:@"Name"];
labelSection.text = name;
关于ios - 通过 plist 的 TableView 部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26642429/