iOS Development Basics-Fragmentation 23

Source: Internet
Author: User

1: About row-to-duplicate loading in UITableView

Rewrite the prepareforreuse in the cell , emptying some controls;

Relatively simple:-(void) prepareforreuse{    [Super Prepareforreuse];    _content_label.text = nil;    _time_date_label.text = nil;    _name_label.text = nil;    _career_label.text = nil;} The following is a custom view that I loaded in the cell Blsprincipalitemview

-(void) Prepareforreuse

{

[Super prepareforreuse];

self. Titlelabel. Text = nil;

for (UIView *view in [self. Contentview subviews])

{

if ([View iskindofclass: [blsprincipalitemview class]])

{

[View Removefromsuperview];

}

}

}

Pay attention to Self.contentview, otherwise there will be no effect in IOS7, or repeat the increase with the picture confusion

There's a section here. A detailed description of it:

Cell is reused how to know in advance? The Prepareforreuse official header file that rewrites the cell is described in. If the currently allocated cell is reused (usually scrolled out of the screen), the cell's Prepareforreuse notification cell is called. Note that when this method is overridden, Note Be sure to call the parent class method [Super Prepareforreuse]. This is especially important when using the cell as a proxy container for network access, where you need to be notified to cancel the previous network request. Stop sending data to this cell.-(void) prepareforreuse{    [Super Prepareforreuse];} Custom UITableViewCell methods There are a lot of ways to find out that some people will encounter the problem of image confusion in their defined cell. This is often caused by the lack of implementation of the Prepareforreuse method. UITableViewCell Reuse when scrolling down , the cell that is used is the one that slides out, and the information that slides out of the cell shows up here. The solution is to implement the Perpareforreuse method in the subclass of UITableViewCell and empty the contents.

2: View the path to the virtual device

    NSString *path = Nshomedirectory ();//main directory    NSLog (@ "nshomedirectory:%@", Path);

3:ios8 Simulator Path

The path before IOS 8.0 is as follows:/users/testuser/library/application Support/iphone Simulatorios 8.0 After the path is as follows:/users/testuser/library/ Developer/coresimulator/devices/8978b626-387e-40af-ae99-6dee931c5fa4/data/containers/data/application

4:cocoalumberjack location of log file generation

/users/testuser/library/developer/coresimulator/devices/8978b626-387e-40af-ae99-6dee931c5fa4/data/containers/ data/application/7ca2354e-5b3a-47e2-8f69-a59764538fa1/library/caches/logs/

5:webview loading the news URL

    Self.webview = [[UIWebView alloc] initwithframe:cgrectmake (0.0, 0.0, screenwidth, screenheight)];    Self.webView.delegate = self;    Nsurl *url = [Nsurl URLWithString:self.urlStr];    Nsurlrequest *request = [Nsurlrequest requestwithurl:url];    [Self.webview loadrequest:request];       [Self.view AddSubview:self.webView];

6: Multi-finger multi-click response

-(void) viewdidload {    [super viewdidload];        UITapGestureRecognizer *myfingerstwotaps =    [[UITapGestureRecognizer alloc] initwithtarget:self action:@ Selector (fingerstaps)];    [Myfingerstwotaps Setnumberoftapsrequired:4];    [Myfingerstwotaps Setnumberoftouchesrequired:2];    [Self view] addgesturerecognizer:myfingerstwotaps];} -(void) Fingerstaps {    NSLog (@ "Action: two fingers  continuous click");}

7: Add a PCH file to the step

1: Create a new file ios->other->pch files, create a PCH file: "Project name-prefix.pch": 2: Add the path of precompile header option in building setting to "$ ( Srcroot)/project name/pch file name "(For example: $ (srcroot)/lotteryfive/lotteryfive-prefix.pch) 3: precompile Prefix Header Yes, Pre-compiled PCH files are cached to improve compilation speed

8: Hide status bar with navigation bar

Viewwillappear indicates that the view will be rendered before-(void) Viewwillappear: (BOOL) animated{    [Super viewwillappear:animated];    [Self.navigationController.navigationBar Settranslucent:yes];    [Self.navigationcontroller Setnavigationbarhidden:yes];}

9: Modify the table row default separator line spacing problem

    if (!_mytableview) {        _mytableview = [[UITableView alloc] initWithFrame:self.view.bounds style: Uitableviewstyleplain];        _mytableview.backgroundcolor = [Uicolor clearcolor];        _mytableview.showsverticalscrollindicator = NO;        _mytableview.showshorizontalscrollindicator=no;                _mytableview.tablefooterview=[[uiview Alloc]init];        _mytableview.datasource = self;        _mytableview.delegate = self;        [_mytableview Registerclass:[uitableviewcell class] Forcellreuseidentifier:blsmaterialdocumentsviewcontroller_ Cellidentifier];        [Self.view Addsubview:_mytableview];                if ([Self.mytableview respondstoselector: @selector (setlayoutmargins:)]) {            self.mytableview.layoutmargins= Uiedgeinsetszero;        }        if ([Self.mytableview respondstoselector: @selector (setseparatorinset:)]) {            self.mytableview.separatorinset= Uiedgeinsetszero;        }    }
-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{    Lefttablecell *cell = [TableView dequeuereusablecellwithidentifier:nsstringfromclass ([Lefttablecell class]) Forindexpath:indexpath];    Cell.curlefttagmodel = [Self.datalist objectAtIndex:indexPath.section];    cell.hasbeenselected = (Cell.curlefttagmodel==self.curselectmodel);            To modify the table row default separator spacing problem    if ([Cell respondstoselector: @selector (setlayoutmargins:)]) {        cell.layoutmargins= Uiedgeinsetszero;    }    if ([Cell respondstoselector: @selector (setseparatorinset:)]) {        cell.separatorinset=uiedgeinsetszero;    }        return cell;}

iOS Development Basics-Fragmentation 23

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.