数组数据

来源:互联网 发布:快速迭代收缩阈值算法 编辑:程序博客网 时间:2024/05/29 19:51
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(77, 191, 86);"><span style="font-variant-ligatures: no-common-ligatures">AppDelegate.m</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(77, 191, 86);"><span style="font-variant-ligatures: no-common-ligatures"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">- (</span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">BOOL</span><span style="font-variant-ligatures: no-common-ligatures">)application:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">UIApplication</span><span style="font-variant-ligatures: no-common-ligatures"> *)application didFinishLaunchingWithOptions:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">NSDictionary</span><span style="font-variant-ligatures: no-common-ligatures"> *)launchOptions {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(0, 175, 202);"><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #93c96a">window</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> = [[</span><span style="font-variant-ligatures: no-common-ligatures">UIWindow</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">alloc</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">]</span><span style="font-variant-ligatures: no-common-ligatures">initWithFrame</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">:[</span><span style="font-variant-ligatures: no-common-ligatures">UIScreen</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">mainScreen</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">].</span><span style="font-variant-ligatures: no-common-ligatures">bounds</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(0, 175, 202);"><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #93c96a">window</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">.</span><span style="font-variant-ligatures: no-common-ligatures">rootViewController</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> = [[</span><span style="font-variant-ligatures: no-common-ligatures">UINavigationController</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">alloc</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">]</span><span style="font-variant-ligatures: no-common-ligatures">initWithRootViewController</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">:[[</span><span style="font-variant-ligatures: no-common-ligatures; color: #93c96a">MyTableViewController</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">alloc</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">]</span><span style="font-variant-ligatures: no-common-ligatures">initWithStyle</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">:</span><span style="font-variant-ligatures: no-common-ligatures">UITableViewStyleGrouped</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">]];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(0, 175, 202);"><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">    [</span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #93c96a">window</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">makeKeyAndVisible</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(194, 52, 155);"><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">    </span><span style="font-variant-ligatures: no-common-ligatures">return</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">YES</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">}</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(77, 191, 86);"><span style="font-variant-ligatures: no-common-ligatures">MyTableViewController.m</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(147, 201, 106);"><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">@interface</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">MyTableViewController</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> ()</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(77, 191, 86);"><span style="font-variant-ligatures: no-common-ligatures">//<NSArray*>  </span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">泛型,</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">类型</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">参数化技术</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(194, 52, 155);"><span style="font-variant-ligatures: no-common-ligatures">@property</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">(</span><span style="font-variant-ligatures: no-common-ligatures">nonatomic</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">,</span><span style="font-variant-ligatures: no-common-ligatures">strong</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">)</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">NSArray</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"><</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">NSArray</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">*> *dataArray;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(194, 52, 155);"><span style="font-variant-ligatures: no-common-ligatures">@end</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">@implementation</span><span style="font-variant-ligatures: no-common-ligatures"> MyTableViewController</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">-(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">NSArray</span><span style="font-variant-ligatures: no-common-ligatures"> *)dataArray {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">if</span><span style="font-variant-ligatures: no-common-ligatures"> (</span><span style="font-variant-ligatures: no-common-ligatures; color: #93c96a">_dataArray</span><span style="font-variant-ligatures: no-common-ligatures"> == </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">nil</span><span style="font-variant-ligatures: no-common-ligatures">) {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(228, 67, 71);"><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">        </span><span style="font-variant-ligatures: no-common-ligatures; color: #93c96a">_dataArray</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #8b84cf">@[@[</span><span style="font-variant-ligatures: no-common-ligatures">@"</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">盖伦</span><span style="font-variant-ligatures: no-common-ligatures">"</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">,</span><span style="font-variant-ligatures: no-common-ligatures">@"</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">景辉</span><span style="font-variant-ligatures: no-common-ligatures">"</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">,</span><span style="font-variant-ligatures: no-common-ligatures">@"</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">夏侯渊</span><span style="font-variant-ligatures: no-common-ligatures">"</span><span style="font-variant-ligatures: no-common-ligatures; color: #8b84cf">]</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">,</span><span style="font-variant-ligatures: no-common-ligatures; color: #8b84cf">@[</span><span style="font-variant-ligatures: no-common-ligatures">@"</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">妮莉艾露</span><span style="font-variant-ligatures: no-common-ligatures">"</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">, </span><span style="font-variant-ligatures: no-common-ligatures">@"</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">纲手</span><span style="font-variant-ligatures: no-common-ligatures">"</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">,</span><span style="font-variant-ligatures: no-common-ligatures">@"</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">貂蝉</span><span style="font-variant-ligatures: no-common-ligatures">"</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">,</span><span style="font-variant-ligatures: no-common-ligatures">@"</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">西施</span><span style="font-variant-ligatures: no-common-ligatures">"</span><span style="font-variant-ligatures: no-common-ligatures; color: #8b84cf">]]</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    }</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(147, 201, 106);"><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">return</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">_dataArray</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">}</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">- (</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">NSInteger</span><span style="font-variant-ligatures: no-common-ligatures">)numberOfSectionsInTableView:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">UITableView</span><span style="font-variant-ligatures: no-common-ligatures"> *)tableView {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(194, 52, 155);"><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">    </span><span style="font-variant-ligatures: no-common-ligatures">return</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #93c96a">dataArray</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">count</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">}</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">- (</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">NSInteger</span><span style="font-variant-ligatures: no-common-ligatures">)tableView:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">UITableView</span><span style="font-variant-ligatures: no-common-ligatures"> *)tableView numberOfRowsInSection:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">NSInteger</span><span style="font-variant-ligatures: no-common-ligatures">)section {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: 'PingFang SC'; color: rgb(77, 191, 86);"><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures; color: rgb(49, 213, 206);">    </span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">//</span><span style="font-variant-ligatures: no-common-ligatures">该行代码</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">会根据</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">左边的类型</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">进行</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">自动的隐式类型转换,</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">转换为</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> array</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(77, 191, 86);"><span style="font-variant-ligatures: no-common-ligatures">//    NSArray *array = self.dataArray[section];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures">    </span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: 'PingFang SC'; color: rgb(77, 191, 86);"><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures; color: rgb(49, 213, 206);">    </span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">//</span><span style="font-variant-ligatures: no-common-ligatures">直接从数组取元素</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">是</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> id </span><span style="font-variant-ligatures: no-common-ligatures">类型,需要转换成数组,才能使用数组的</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">count</span><span style="font-variant-ligatures: no-common-ligatures">属性</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(77, 191, 86);"><span style="font-variant-ligatures: no-common-ligatures">//    return ((NSArray*)self.dataArray[section]).count;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures">    </span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: 'PingFang SC'; color: rgb(77, 191, 86);"><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures; color: rgb(49, 213, 206);">    </span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">//</span><span style="font-variant-ligatures: no-common-ligatures">如果</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">泛型</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">是</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> <NSArray*> </span><span style="font-variant-ligatures: no-common-ligatures">那么取出的元素就是数组,</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">所以不用再做类型转换</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">return</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">self</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #93c96a">dataArray</span><span style="font-variant-ligatures: no-common-ligatures">[section].</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">count</span><span style="font-variant-ligatures: no-common-ligatures">;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">}</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">- (</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">UITableViewCell</span><span style="font-variant-ligatures: no-common-ligatures"> *)tableView:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">UITableView</span><span style="font-variant-ligatures: no-common-ligatures"> *)tableView cellForRowAtIndexPath:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">NSIndexPath</span><span style="font-variant-ligatures: no-common-ligatures"> *)indexPath {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(0, 175, 202);"><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">    </span><span style="font-variant-ligatures: no-common-ligatures">UITableViewCell</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> *cell = [tableView </span><span style="font-variant-ligatures: no-common-ligatures">dequeueReusableCellWithIdentifier</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #e44347">@"id"</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">if</span><span style="font-variant-ligatures: no-common-ligatures"> (cell == </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">nil</span><span style="font-variant-ligatures: no-common-ligatures">) {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(0, 175, 202);"><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">        cell = [[</span><span style="font-variant-ligatures: no-common-ligatures">UITableViewCell</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">alloc</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">]</span><span style="font-variant-ligatures: no-common-ligatures">initWithStyle</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">:</span><span style="font-variant-ligatures: no-common-ligatures">UITableViewCellStyleDefault</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">reuseIdentifier</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #e44347">@"id"</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    }</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures">    </span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">NSString</span><span style="font-variant-ligatures: no-common-ligatures"> *name = </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">self</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #93c96a">dataArray</span><span style="font-variant-ligatures: no-common-ligatures">[indexPath.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">section</span><span style="font-variant-ligatures: no-common-ligatures">][indexPath.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">row</span><span style="font-variant-ligatures: no-common-ligatures">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures">    </span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    cell.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">textLabel</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">text</span><span style="font-variant-ligatures: no-common-ligatures"> = name;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures">    </span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">return</span><span style="font-variant-ligatures: no-common-ligatures"> cell;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">}</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: 'PingFang SC'; color: rgb(77, 191, 86);"><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">//</span><span style="font-variant-ligatures: no-common-ligatures">如果</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">分区头</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">使用的是</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> View </span><span style="font-variant-ligatures: no-common-ligatures">的话,必须设置分区头的</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">高度</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">-(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">CGFloat</span><span style="font-variant-ligatures: no-common-ligatures">)tableView:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">UITableView</span><span style="font-variant-ligatures: no-common-ligatures"> *)tableView heightForHeaderInSection:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">NSInteger</span><span style="font-variant-ligatures: no-common-ligatures">)section {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">return</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #8b84cf">44</span><span style="font-variant-ligatures: no-common-ligatures">;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">}</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">-(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">UIView</span><span style="font-variant-ligatures: no-common-ligatures">*)tableView:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">UITableView</span><span style="font-variant-ligatures: no-common-ligatures"> *)tableView viewForHeaderInSection:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">NSInteger</span><span style="font-variant-ligatures: no-common-ligatures">)section {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(0, 175, 202);"><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">    </span><span style="font-variant-ligatures: no-common-ligatures">UILabel</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> *label = [[</span><span style="font-variant-ligatures: no-common-ligatures">UILabel</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> </span><span style="font-variant-ligatures: no-common-ligatures">alloc</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">]</span><span style="font-variant-ligatures: no-common-ligatures">init</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    label.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">frame</span><span style="font-variant-ligatures: no-common-ligatures"> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">CGRectMake</span><span style="font-variant-ligatures: no-common-ligatures">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #8b84cf">0</span><span style="font-variant-ligatures: no-common-ligatures">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #8b84cf">0</span><span style="font-variant-ligatures: no-common-ligatures">, tableView.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">frame</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">size</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">width</span><span style="font-variant-ligatures: no-common-ligatures">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #8b84cf">44</span><span style="font-variant-ligatures: no-common-ligatures">);</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    label.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00afca">text</span><span style="font-variant-ligatures: no-common-ligatures"> = section == </span><span style="font-variant-ligatures: no-common-ligatures; color: #8b84cf">0</span><span style="font-variant-ligatures: no-common-ligatures"> ? </span><span style="font-variant-ligatures: no-common-ligatures; color: #e44347">@"</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures; color: rgb(228, 67, 71);">男生</span><span style="font-variant-ligatures: no-common-ligatures; color: #e44347">"</span><span style="font-variant-ligatures: no-common-ligatures"> : </span><span style="font-variant-ligatures: no-common-ligatures; color: #e44347">@"</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures; color: rgb(228, 67, 71);">女生</span><span style="font-variant-ligatures: no-common-ligatures; color: #e44347">"</span><span style="font-variant-ligatures: no-common-ligatures">;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(0, 175, 202);"><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">    label.</span><span style="font-variant-ligatures: no-common-ligatures">textAlignment</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce"> = </span><span style="font-variant-ligatures: no-common-ligatures">NSTextAlignmentCenter</span><span style="font-variant-ligatures: no-common-ligatures; color: #31d5ce">;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206); min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c2349b">return</span><span style="font-variant-ligatures: no-common-ligatures"> label;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(49, 213, 206);"><span style="font-variant-ligatures: no-common-ligatures">}</span></p>



0 0