[A gull's training note] [Objective-c] [Fifth day] [Personal notes]

Source: Internet
Author: User

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]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.