Keywords: ratreeview sister
Sunday Night meet a sister with Ratreeview (GitHub link), want to change the level two cell height. This library I have not contacted, but, the other is sister, tomorrow also to cross, then the bullet-bite to see the code bar. Did not expect this library structure is very clear, is really the industry conscience. Now old, a lot of things done on the forget, when the log is written. The procedure for finding a problem is documented below.
1, run the demo first. If you can't run, it's really a pit-daddy. However, free things, do not ask too much, there is code is very kind, after all, provide a reference. The demo was changed by sister, fortunately the function is relatively single.
2, look appdelegate, find Rootviewcontroller.
1-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) Launchoptions2 {3Self.window =[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds];4 if([[Uidevice currentdevice] userinterfaceidiom] = =Uiuserinterfaceidiomphone) {5Self.viewcontroller = [[Raviewcontroller alloc] Initwithnibname:@"Raviewcontroller_iphone"Bundle:nil];6}Else {7Self.viewcontroller = [[Raviewcontroller alloc] Initwithnibname:@"Raviewcontroller_ipad"Bundle:nil];8 }9Self.window.rootViewController =Self.viewcontroller;Ten [Self.window makekeyandvisible]; One returnYES; A}
From the code, Raviewcontroller is the root controller.
3, find Raviewcontroller viewdidload, viewwillappear and other life cycle methods. Find the following code in Viewdidload:
1Ratreeview *treeview =[[Ratreeview alloc] initWithFrame:self.view.frame];2 3Treeview.Delegate=Self ;4Treeview.datasource =Self ;5Treeview.separatorstyle =Ratreeviewcellseparatorstylesingleline;6 7 [TreeView Reloaddata];8[TreeView Expandrowforitem:phone Withrowanimation:ratreeviewrowanimationnone];//expands Row9 [TreeView setbackgroundcolor:[uicolor redcolor];Ten OneSelf.treeview = TreeView;
Raviewcontroller only covers the viewdidload, the view that the application renders is the result of the operation of 11 rows Self.treeview = TreeView.
4, affected by experience, find the Heightfor method, find the treeView:heightForRowForItem:treeNodeInfo:
return value of cgfloat, that basically it is in control height.
1 #pragmaMark TreeView Delegate Methods2-(CGFloat) TreeView: (Ratreeview *) TreeView Heightforrowforitem: (ID) Item Treenodeinfo: (Ratreenodeinfo *) Treenodeinfo3 {4 if(Treenodeinfo.treedepthlevel = =0) {5 return -;6}if(Treenodeinfo.treedepthlevel = =1&& Treenodeinfo.siblingsnumber = =0) {7 return -;8 }9 return -;Ten}
Sister want to control the level two cell height, that the 6th line of code if (treenodeinfo.treedepthlevel = = 1 && treenodeinfo.siblingsnumber = = 0) should be judged two-level cell, decisive change , the new code is as follows:
1 #pragmaMark TreeView Delegate Methods2-(CGFloat) TreeView: (Ratreeview *) TreeView Heightforrowforitem: (ID) Item Treenodeinfo: (Ratreenodeinfo *) Treenodeinfo3 {4 if(Treenodeinfo.treedepthlevel = =0) {5 return -;6}if(Treenodeinfo.treedepthlevel = =1/*&&treenodeinfo.siblingsnumber = = 0*/) {7 if([Item Iskindofclass:[radataobjectclass]]){8Radataobject *dataobject = (radataobject*) Item;9 if([Dataobject.name isequaltostring:@"Phone 1"]) {Ten return Max; One } A } - return -; - } the return -; -}
Sample code, hard-coded, lazy to do, run after the sister a look, get, on this flavor. OK, keep looking at Homeland security.
Summary: There is a yarn summary.
IOS 8: Help sister debug third-party libraries-Ratreeview