Simple use of iOS_10_tableView
Finally:
Method 1: dictionary Array
BeyondViewController. h
//// BeyondViewController. h // 10_tableView /// Created by beyond on 14-7-25. // Copyright (c) 2014 com. beyond. all rights reserved. // # import <UIKit/UIKit. h> @ interface BeyondViewController: UIViewController @ end
BeyondViewController. m
//// BeyondViewController. m // 10_tableView /// Created by beyond on 14-7-25. // Copyright (c) 2014 com. beyond. all rights reserved. // # import "BeyondViewController. h "# define kHeader @" header "# define kFooter @" footer "# define kGirlsArr @" girls "@ interface BeyondViewController () <UITableViewDataSource >{// false data NSArray * _ array;} @ end @ implementation BeyondViewController-(void) viewDidLoad {[super viewDidLo Ad]; // false data method 1 Use dictionary _ array = @ [@ {kHeader: @ "", kGirlsArr: @ [@ "Lin Daiyu ", @ "Xue Baochai", @ "Jia yuanchun", @ "Jia Xinchun", @ "Shi Xiangyun", @ "Miao Yu", @ "Jia Yingchun", @ "Jia Xinchun ", @ "Wang Xifeng", @ "Jia qiaojie", @ "Li Xiao", @ "Qin keqing"], kFooter: @ "Dream of Red Mansions"}, @ {kHeader: @ "", kGirlsArr: @ [@ "xiangling", @ "Xue baoqin", @ "youerjie", @ "yousanjie ", @ "", @ "xia jingui", @ "Qiu Tong", @ "xiao hong", @ "Ling Guan ", @ "Charming apricot"], kFooter: @ "Dream of Red Mansions"}, @ {kHeader: @ "", kGirlsArr: @ [@ "Qingwen ", @ "attacked", @ "Pinger", @ "zookeeper", @ "zixiao", @ "Xiaoer", @ "yuyun", @ "Jin Yun", @ "caiyun ", @ "Si Qi", @ "fang Guan", @ "" Month "], kFooter: @" Dream of Red Mansions "}]; // false data method 2 class encapsulation // style only two Grouped PlainUITableView * tableView = [[UITableView alloc] initWithFrame: self. view. bounds style: UITableViewStyleGrouped]; // data source tableView. dataSource = self; // Add to self. view [self. view addSubview: tableView];} // data source method, special case, important ~ Total number of groups-(NSInteger) numberOfSectionsInTableView :( UITableView *) tableView {return _ array. count;} // data source method. The number of rows in each group-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section {// return the length of the dictionary in the array. return [[_ array [section] objectForKey: kGirlsArr] count];} // data source method, how should I display the interface (including encapsulated data) for each row in each group !!! Otherwise, Terminating app due to uncaught exception 'failed', reason: 'uitableview dataSource must return a cell from tableView: cellForRowAtIndexPath: '-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath {static NSString * cellID = @ "Beyond"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: cellID]; if (cell = nil) {// if the pool is not obtained, a new four cell/* cell styles are generated: 1. default: left text 2; default: left text 2; subtitle: Left Text 3: Large Text 3, value 1 left graph large right text small 3, value 2 disgusting left text small right text large */cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: cellID];} // set the unique content cell in the cell. textLabel. text = [_ array [indexPath. section] objectForKey: kGirlsArr] [indexPath. row]; // return cell;} // data source method. What title is displayed at the beginning of the group?-(NSString *) tableView :( UITableView *) tableView titleForHeaderInSection :( NSInteger) section {return [_ array [section] objectForKey: kHeader];} // data source method, and the title displayed at the end of the group //-(NSString *) tableView :( UITableView *) tableView titleForFooterInSection :( NSInteger) section // {// return [_ array [section] objectForKey: kFooter]; //} @ end
Method 2: replace the dictionary in the array with a class (model)
TwelveBeauties. h
/// TwelveBeauties. h // 10_tableView /// Created by beyond on 14-7-26. // Copyright (c) 2014 com. beyond. all rights reserved. // # import <Foundation/Foundation. h> // corresponding to viewController. A member in the member array in m --> dictionary @ interface TwelveBeauties: NSObject // weak is used when the UI control is connected, copy is used for the string, and strong @ property (nonatomic, copy) is used for other objects) NSString * header; @ property (nonatomic, copy) NSString * footer; @ property (nonatomic, strong) NSArray * girls; // provides a class method, A constructor starting with a Class Name (the returned id is also acceptable) + (TwelveBeauties *) twelveBeautiesWithHeader :( NSString *) header footer :( NSString *) footer girls :( NSArray *) girls; @ end
TwelveBeauties. m
/// TwelveBeauties. m // 10_tableView /// Created by beyond on 14-7-26. // Copyright (c) 2014 com. beyond. all rights reserved. // # import "TwelveBeauties. h "@ implementation TwelveBeauties // provides a class method, a construction method starting with the class name (the return id can also be) + (TwelveBeauties *) twelveBeautiesWithHeader :( NSString *) header footer :( NSString *) footer girls :( NSArray *) girls {TwelveBeauties * twelveBeauties = [[TwelveBeauties alloc] init]; twelveBeauties. header = header; twelveBeauties. footer = footer; twelveBeauties. girls = girls; return twelveBeauties;} @ end
BeyondViewController. m
//// BeyondViewController. m // 10_tableView /// Created by beyond on 14-7-25. // Copyright (c) 2014 com. beyond. all rights reserved. // # import "BeyondViewController. h "# import" TwelveBeauties. h "@ interface BeyondViewController () <UITableViewDataSource >{// false data NSArray * _ array;} @ end @ implementation BeyondViewController-(void) viewDidLoad {[super viewDidLoad]; // false data method 1 use the dictionary/* _ array = @ [@ {kHeader: @ "正 Volume ", kGirlsArr: @ [@" Lin Daiyu ", @" Xue Baochai ", @" Jia yuanchun ", @" Jia Xinchun ", @" Shi Xiangyun ", @" Miao Yu ", @ "Jia Yingchun", @ "Jia Yingchun", @ "Wang Xifeng", @ "Jia qiaojie", @ "Li Xiao", @ "Qin keqing"], kFooter: @ "Dream of Red Mansions"}, @ {kHeader: @ "", kGirlsArr: @ [@ "xiangling", @ "Xue baoqin", @ "", @ "yousanjie", @ "", @ "Li Wen", @ "Li Yun", @ "xia jingui", @ "Qiu Tong", @ "xiao hong ", @ "aging officer", @ "Jiao Xing"], kFooter: @ "Dream of Red Mansions"}, @ {kHeader: @ "", kGirlsArr: @ [@ "Qingwen", @ "attacked", @ "Pinger", @ "zhuyun", @ "Ziyun", @ "zhuer", @ "yuyun ", @ "Jin Yun", @ "", @ "Si Qi", @ "fang Guan", @ ""], kFooter: @ ""}]; * /// false data method 2: Class encapsulation, post _ arra Y = @ [[TwelveBeauties twelveBeautiesWithHeader: @ "" footer: @ "Dream of Red Mansions" girls: @ ["> @" Lin Daiyu ", @" Xue Baochai ", @ "Jia yuanchun", @ "Jia Xinchun", @ "Shi Xiangyun", @ "Miao Yu", @ "Jia Yingchun", @ "Jia Xinchun", @ "Wang Xifeng ", @ "Jia qiaojie", @ "li ke", @ "Qin keqing"], [TwelveBeauties twelveBeautiesWithHeader: @ "" footer: @ "" girls: @ [@ "xiangling", @ "Xue baoqin", @ "", @ "Li Wen ", @ "Li Yun", @ "xia jingui", @ "Qiu Tong", @ "xiao hong", @ "Ling Guan", @ "Jiao Xing"], [TwelveBeauties twelveBeautiesWithHeader: @ "" footer: @ "Dream of Red Mansions" girls: @ [@ "Qingwen", @ "Attack Man ", @" Pinger ", @" zookeeper ", @" zixiao ", @" Xiaoer ", @" Yu yu ", @" Jin Yun ", @" caiyun ", @ "si", @ "", @ ""]; // there are only two types of styles: Grouped PlainUITableView * tableView = [[UITableView alloc] initWithFrame: self. view. bounds style: UITableViewStyleGrouped]; // data source tableView. dataSource = self; // Add to self. view [self. view addSubview: tableView];} // data source method, special case, important ~ Total number of groups-(NSInteger) numberOfSectionsInTableView :( UITableView *) tableView {return _ array. count;} // data source method. The number of rows in each group-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section {// return the length of the dictionary in the array // return [[_ array [section] objectForKey: kGirlsArr] count]; // TwelveBeauties * twelveBeauties = _ array [section]; return twelveBeauties. girls. count;} // data source method. What should I display for each row in each group? Interface (including encapsulated data), focus !!! Otherwise, Terminating app due to uncaught exception 'failed', reason: 'uitableview dataSource must return a cell from tableView: cellForRowAtIndexPath: '-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath {static NSString * cellID = @ "Beyond"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: cellID]; if (cell = nil) {// if the pool is not obtained, a new four cell/* cell styles are generated: 1. default: left text 2; default: left text 2; subtitle: Left Text 3: Large Text 3, value 1 left graph large right text small 3, value 2 disgusting left text small right text large */cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: cellID];} // set the unique content in the cell. The dictionary encapsulates false data. // cell. textLabel. text = [_ array [indexPath. section] objectForKey: kGirlsArr] [indexPath. row]; // TwelveBeauties * twelveBeauties = _ array [indexPath. section]; cell. textLabel. text = [twelveBeauties. girls objectAtIndex: indexPath. row]; // return cell;} // data source method. What title is displayed at the beginning of the group?-(NSString *) tableView :( UITableView *) tableView titleForHeaderInSection :( NSInteger) section {// dictionary encapsulation of false data // return [_ array [section] objectForKey: kHeader]; // TwelveBeauties * twelveBeauties = _ array [section] After data model encapsulation; return twelveBeauties. header;} // data source method, the group index title (the rightmost vertical bar in the address book)-(NSArray *) sectionIndexTitlesForTableView :( UITableView *) tableView {// use KVC \ KVO to implement return @ [@ "", @ "", @ ""] in a code sentence; // NSMutableArray * array = [NSMutableArray array]; // for (TwelveBeauties * tb in _ array) {// [array addObject: tb. header]; //} // NSLog (@ "% @", array); // return array;} @ end
Q: What is the ranking of the twelve NOPs in A Dream of Red Mansions?
Daiyu funeral flower
Baodi butterfly
Yuan Chun
Yingchun Jingjing
Spring Association
Qingchun Diagram
Xiangyun Qilin
Li Shu
Fengjie
Qiaojie
Ke qingchunxian
Miao Yufeng tea
Lin Daiyu
Lin ruhai is the only daughter of Jia Min. Because her parents died successively, her grandmother pity her loneliness and received the support from rongguo government. Although she is an orphan, she is proud and innocent. She and baoyu are both feudal rebels and never persuaded Baoyu to go through the feudal official path. She despised the power of fame and privilege. When Jia Baoyu gave her a string of valuable beads from the Holy Lord Bejing, she said, "I don't want this stupid man !" She and baoyu share the same ideals and interests, and truly love each other. But this love was cruelly killed by Jia Mu and others, and Lin Daiyu died in tears.
Xue Baochai
Aunt Xue's daughter, one of the twelve NOPs in Jinling, has a wealth of millions in her family. Her appearance is beautiful, her muscles are shining, and her manners are elegant. She is keen on the "shitu economy" and urges Baoyu to become an official officer. She talks about shitu economy and is secretly called "mixed account" by Baoyu ". She abides by the feudal wude, and is deeply rooted in the city. She is praised by Jia Fu. She hung up a golden lock with a "never leave, forever, forever", and Xue's aunt said, "you have to pick up the gold lock to match with the jade ", under the hands of Jia Mu and Mrs. Wang, Jia Baoyu was forced to marry Xue Baochai. Due to the lack of common ideals and interests between the two parties, Jia Baoyu could not forget Zhiyin Lin Daiyu. Soon after marriage, he became a monk. Xue Baochai had to stay empty and hate for life.
Wang Xifeng
The wife of Jia Yu, one of the twelve NOPs in Jinling, is the inner and niece of Mrs. Wang. Long with a pair of Danfeng triangle eyes, two-bend willow leaves hanging eyebrows, slim body, physical cool. She is brilliant and powerful, gaining the trust of Jia Mu and Mrs. Wang and becoming the real manager of Jia Fu. She exists on the throne of several hundred people in Jia Fu, where eloquence and power are the weapons of her upper-right deception. Her purpose is to seize power and accumulate wealth. She was so powerful that she could be cool, even though Jia Rui? The children are dead, but the "poisonous Acacia Bureau" also shows the cruelty of their revenge. In order to make a bribe of three thousand silver coins, the "Li Quan tiexiao Temple" forced both the daughter of Zhang's family and the son of a guard to do their best. You second sister and the fetus in her abdomen were also killed by Wang Xifeng in the most sophisticated and vicious way. She openly declared: "I have never believed in any ysh-sash retribution. I just want to say that !" She was extremely greedy. In addition to asking for bribes, she had to pay off her debt by sending late public payment monthly bills. Just like this, she turned out hundreds or even thousands of pieces of silver to make money. When copying a house, she copied 70 thousand yuan and a box of coupons from her house. What Wang Xifeng did is undoubtedly accelerating Jia's defeat. Finally, he finally got the end of "the machine is too intelligent to count the lives of Xiao Qing.
Li Yun
Zi Gong cutting, Jia Zhu's wife, has a son Jia Lan. She was born from Jinling minghuan, and her father Li shouzhong once sacrificed wine for her country. Since she was a child, she was educated by her father "female without talent is morality". She recognized a few words and remembered that there were several sages in the past. Every day, she wanted to see textile women. Jia Zhu died in less than 20 years old. Li Yao has always been widowed. Although he is in the ointment, he knows how to raise a parent-child, and when he is idle, he will not care about it. She is a typical example of a virtuous lady who abides by the feudal etiquette law.
Jia yuanchun
JIA Zheng and the eldest daughter of Mrs Wang. From childhood by Jia Mu education. As a elder sister, when she was three or four years old, she had taught her to read and write. Although she was a brother-in-law, she was like a mother and child. Afterwards, because of the good filial piety and talent, the house was chosen as a female. Soon, Feng algae palace Shang Shu, Jia Feng Xiande Fei. To greet her, Jia built a provincial villa. The villa is luxurious, and even yuan chunyuan feels too luxurious! Although yuan Fei gave Jia a "hot cooking oil, flowers with a rich brocade", she was quietly closed in the royal palace. She said, crying, and describing the Palace Hall as a "uninteresting place to see ". After this time, Yuan Fei had no chance to go out of the palace, and then died of sudden illness.
Jia Yingchun
Those born of Jia Yi and Qi are listed as Miss Jia fu'er. She is honest and incompetent, weak and afraid of things, and has the nickname of "Two wood. Not only does she make poetry guesses, but she is not as good as her sisters. She knows only how to give up and let others bully her life. Her collection of pearl base silk jinfeng jewelry was used by people to gamble, she did not investigate, others tried to recover for her, but she said: "I 'd rather not, why should I be angry ." Her father, Jia, owes Sun's house five thousand ...... the rest of the article>
Who are the twelve secrets in A Dream of Red Mansions?
Jinling twelve NOPs
The twelve catties in Jinling are from the famous Chinese classical literature Dream of Red Mansions (also known as stone and Jin Yuyuan)
Jinling twelve noisy: Lin Daiyu, Xue Baochai, Shi Xiangyun, Wang Xifeng, Jia Yingchun, Jia Yingchun, Jia yuanchun, Jia Xinchun, Qin keqing, Li Yu, Miao Yu, Jia qiaojie.
1. Lin Daiyu
The two curves are like a pair of non-empty-box smokes. The two sides of the sorrow, Jiao attack a disease. With little tears, you can breathe your breath. Quiet as charming as water, actions such as weak Liu fufeng. The heart is better than the stem, and the disease is as good as that of Xi zisheng.
"Doujuanjuan Lin Daiyu" Ling chengshu is the most difficult to tell, and the marriage book is always upside down in this life! We have to fold Acacia to save those troubles. Straight-forward double moth light sweep, a little spring waist. I am afraid that the time is easy to lag, and there are few people with sound. The parrot is also like an idiot, stealing a verse, and knowing it with that person. Recently, there have been no more tears, And the flowers are separated with flowers. However, Zhu Yan was better off with a few strong mirrors. When a burst of wind (Taoist language, high-altitude wind) Evil, wilting red incense, blowing residual grass.
2. Xue Baochai
Dudao is Jin Yu liangyuan [/url; empty face, the mountains goshi crystal snow; sigh the world, the United States is not the current letter: even if it is a simple case, in the end it is difficult. Ren is heartless and touching.
3. Yuan Chun
XI Ronghua is just right, hate impermanence is coming again. Let's let everything go. Loose and carefree. Hope your hometown is high in the distance. Therefore, I want to report to my mother-in-law: My life has entered Huang Quan, Tian Lun, and I need to step back and leave early!
Yuan chunling chengshu
4. Yingchun
Zhongshan wolf, a heartless beast. All do not read the root cause of the day. Blindly, arrogant, lustful, and greedy. While there, Hou men yanzhi with Pu Liu; practice, the Government thousands of Gold seems inferior. With a sigh and a sigh of relief.
5. Spring Festival
Yifan wind and rain road three thousand, the backbone home, flat. Fear of crying for years. Tell me, Hugh's suspense: Since ancient times, the poor communication has been fixed, and the clutch has no chance? From now on, we will be able to ensure security in both locations. The slaves are also implicated.
6. Hunchun
Let's see what the three spring festival looks like? Let this Shaohua go out, find that light day.
What do we say about peach blossom in the sky? In the end, who will see the autumn festival? Let's see it. The people in the poplar village are whining, and the Qingfeng forest is a ghost. Even more, the days of the decline of the grass to cover the grave, this is, the poor and rich man labor, spring and autumn Xie Hua suffering. Like this, who can hide the secrets? Wen said, the western treasure tree called the mother-in-law, with a long fruit on it.
7. Wang Xifeng
The machine is too clever, and I forget my life! The heart is broken before the lifetime, and the spirit is blank after the death. Family rich are better than others; finally, family dead are scattered. I spent a lot of time hanging over the hearts of the rest of the world. Suddenly la is like a tower, and the light will be exhausted. Ah! A joy and sorrow. It's hard to make a sigh!
8. Shi Xiangyun
When my parents are stunned. Who knows how to be pampered? Fortunately, I was born with a great deal of enthusiasm, and never gave my children a private affair. It looks like a breeze and a breeze. You have a wonderful talent, and have a long time. The shape is slightly bumpy when it is young. After a long period of time, the cloud is scattered in the Tang Dynasty, and the water is shining in the Xiangjiang River: why should we be sad?
"Drunk Yin Shi Xiangyun" Ling Cheng Shu Shen Yin Dongfeng flower courtyard quietly, so the grass to find grass. Shi huang semi-segmentation (also "oblique" meaning) oblique, eye-catching, steep sleep good spring. Are there any people in the red? How can I use the green onion R emblem? Wei Chang ?? Why is it true? Mei weiu? Frame?
9. Qin keqing
The painting is full of fragrance dust. If you are good at customs and have a strong sense of the Moon, you will be the root of your defeat. The death of Family Affairs is the first sin. The root cause is love!
10. Miao Yu
The temperament is beautiful, and the talent is better than fairy. Naturally, they are rare. You say it's cool meat, and you're tired of reading it. But you don't know how cool people are, and you're so jealous of the world. You can sigh this, the old lamps will be old, lonely, red powder zhulou spring! In the end, the dust is still a dirty violation of the desire; good look, the white marble is muddy; what is the need, Wang Sun said no.
Ling chengshu, a Buddhist monk, and Miao Yu, arranged the scriptures of the Zen bed. The Buddha Lamp, a pair of yunfang, was quiet. Why is it confusing? The Zen mind should not be clean, and it will bring up the magic of affection. Come up, Acacia inch gray.
11. Qiao Jie
Stay in the Qing Dynasty, stay in the Qing Dynasty, and suddenly meet the benefactor; Lucky Mother, Lucky Mother, the accumulation of Yin gong. Persuade life and help the poor. Hugh is like a zombie who loves silver money and forgets the flesh and blood! It is just multiplication, division, and addition, and there is a sky on it.
12. Li ...... remaining full text>