Tableview+scrollview
- Add label to cell
- Ways to solve ghosting
- Delete element when reusing cell
Nsarray *subviews = cell.subviews;
For (UIView *view in subviews) {
[View Removefromsuperview];
}
- In the IF (Cell==nil), define the child view, plus the tag value. Outside the tag value to get the view, modify the value
- Encapsulates a custom cell class
Http://www.tuicool.com/articles/bE7JNnI
- The method to get the cell from-(uitableviewcell*) Dequeuereusablecellwithidentifier: (nsstring*) identifier for-(UITableViewCell *) Cellforrowatindexpath: (Nsindexpath *) Indexpath. The reuse mechanism is called dequeuereusablecellwithidentifier this method, means " DEQUEUE a reusable cell, so as long as it is swapped for Cellforrowatindexpath (removing the cell only from the row of the cell being updated), the reuse mechanism is not used, so the problem can be solved, although some space may be wasted.
- Resolve by specifying a different reuse identifier (reuseidentifier) for each cell. The reuse mechanism is to reuse cells based on the same identifiers, and cells with different identifiers cannot be reused by each other. So we can avoid the problem of different cell reuse by setting the identifier of each cell to be different.
Http://www.mamicode.com/info-detail-470734.html
Here's a piece of code with ScrollView
1- (void) Viewdidload {2 [Super Viewdidload];3 //control bar? Opaque4Self.navigationController.navigationBar.translucent =NO;5Uiscrollview *scroll =[[Uiscrollview alloc] init];6Scroll.frame =Self.view.frame;7Scroll.backgroundcolor =[Uicolor Darkgraycolor];8Scroll.contentsize = Cgsizemake (self.view.frame.size.width*5, self.view.frame.size.height- -);9NSLog (@"%f",(Double) self.navigationController.navigationBar.frame.size.height);Ten //A page by page slide Onescroll.pagingenabled =YES; AScroll.contentoffset = Cgpointmake (self.view.frame.size.width*2,0); - [Self.view Addsubview:scroll]; - the for(intI=0;i<5; i++) { -UITapGestureRecognizer *tap =[[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (image)]; -Uiimageview *imageview =[[Uiimageview alloc] init]; -imageview.userinteractionenabled =YES; +Imageview.frame = CGRectMake (Self.view.frame.size.width*i,0, Self.view.frame.size.width, self.view.frame.size.height- -); -NSLog (@"%f",(Double) self.navigationController.navigationBar.frame.size.height); +Imageview.image = [UIImage imagenamed:[nsstring stringWithFormat:@"T%d.png", i+1]]; A [ImageView Addgesturerecognizer:tap]; at [scroll addsubview:imageview]; - } - //additional setup after loading the view, typically from a nib. - } - -- (void) image{ inFirstviewcontroller *FIRSTVC = [FirstviewcontrollerNew]; - [Self.navigationcontroller PUSHVIEWCONTROLLER:FIRSTVC animated:yes]; to}
[A gull's training note] [Objective-c] [Fifth day] [Personal notes]