1: Set the table row with spacing (uitableviewstylegrouped)
1. Set the number of sections, that is, how many cells you have-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView {return 3;//in your case, there is 3 cells}2returns a cell for each section.-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (Nsinteger) section{return 1;}3. Set the height of headerview between cells-(CGFloat) TableView: (UITableView *) TableView heightforheaderinsection: (Nsinteger) section{return Ten.;//You can have your own choice, of course}4. Set the color of the Headerview-(UIView *) TableView: (UITableView *) TableView viewforheaderinsection: (nsinteger) section{UIView *headerview = [[Uivie] W alloc] init]; Headerview.backgroundcolor = [Uicolor Clearcolor];returnHeaderview;} Note: You need to use Indexpath.section to get index instead of Indexpath.rowcell.textLabel.text=[nsstring stringWithFormat:@"%@", [array objectAtIndex:indexPath.section]];
Instance:
To Create a table code:if(!_mytableview) {_mytableview= [[UITableView alloc] Initwithframe:cgrectmake (0, Cgrectgetmaxy (Self.customheadView.frame), Main_screen_width, main_screen_height-204) style:uitableviewstylegrouped]; _mytableview.backgroundcolor=[Uicolor Clearcolor]; _mytableview.showsverticalscrollindicator=NO; _mytableview.showshorizontalscrollindicator=NO; _mytableview.datasource=Self ; _mytableview.Delegate=Self ; _mytableview.separatorstyle=Uitableviewcellseparatorstylenone; [_mytableview Registerclass:[blsreplenishmentcellclass] Forcellreuseidentifier:blsreplenishmentviewcontroller_cellidentifier]; [Self.view Addsubview:_mytableview]; } Other methods:#pragmaMark Uitableviewdatasource and uitableviewdelegate-(cgfloat) TableView: (UITableView *) TableView heightforheaderinsection: (nsinteger) section{return Ten;}//if set to 0 the effect will not reach the desired-(CGFloat) TableView: (UITableView *) TableView heightforfooterinsection: (nsinteger) section{return 1;}-(Nsinteger) Numberofsectionsintableview: (nonnull UITableView *) tableview{returnSelf.recordDatalist.count;}-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{return 1;}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{Blsreplenishmentcell*cell =[TableView dequeuereusablecellwithidentifier:blsreplenishmentviewcontroller_cellidentifier ForIndexPath: Indexpath]; Cell.cur_replenishment=[Self.recorddatalist objectAtIndex:indexPath.section]; returncell;}-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) indexpath{return[Blsreplenishmentcell cellheight];}- (void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) indexpath{[TableView Deselectrowatindexpath:indexpath animated:yes];}
2:xcode7 using Nsurlsession to send an HTTP request error
Error content: Console print: Application Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app ' s info.plist file.
Workaround: Modify the Info.plist file
3: Real-time listening length and content to Uitextfield content
// The first step is to add a listener to the component [TextField addtarget:self Action: @selector (textfielddidchange:) forcontrolevents:uicontroleventeditingchanged ];... // The second step is to implement the callback function -(void*_field = (Uitextfield *) sender; NSLog (@ "%@,%d", [_field text],_field.text.length);}
4: Real-Machine Debug Verify that your device's clock is properly set, and that your signing certificate are not expired
Note: in Tagers-build settings--code signing--code signing Identity, the any IOS SDK remembers to select the certificate
5: Add Uitextview to Uialertview and get its value
Mjyalterview.h#import<UIKit/UIKit.h>#import"UIPlaceHolderTextView.h"typedefvoid(^alertviewblock) (Nsinteger index,nsstring *TextValue); @interface mjyalterview:uialertview@property (nonatomic,copy) Alertviewblock block;-(Instancetype) Initwithtitle: (NSString *) title message: (NSString *) message cancelbuttontitle: (NSString *) Cancelbuttontitle otherbuttontitles: (NSString *) otherbuttontitles Clickbutton: (alertviewblock) block; @endMjyAlterView. M#import"MjyAlterView.h"@interface Mjyalterview ()<UIAlertViewDelegate,UITextViewDelegate>@property (copy,nonatomic) NSString*content; @end @implementation Mjyalterview-(Instancetype) Initwithtitle: (NSString *) title message: (NSString *) message cancelbuttontitle: (NSString *) Cancelbuttontitle otherbuttontitles: (NSString *) otherbuttontitles Clickbutton: (alertviewblock) block{ Self= [Super Initwithtitle:title Message:messageDelegate: Self cancelbuttontitle:cancelbuttontitle otherbuttontitles:otherbuttontitles, nil]; Self.backgroundcolor=[Uicolor Whitecolor]; Uiplaceholdertextview*textview =[[Uiplaceholdertextview alloc]init]; TextView.Delegate=Self ; Textview.font=[uifont systemfontofsize: the]; Textview.placeholder=@"Input Content"; TextView.layer.borderColor=[Uicolor Graycolor]. Cgcolor; TextView.layer.borderWidth=0.5; //if (System_version_less_than (@ "7.0"))//When the system is IOS7// { //[Testalert Addsubview:textview]; // } //Else//when the system is IOS8// {[Self Setvalue:textview forkey:@"Accessoryview"]; // } if(self) {_block=Block; } returnSelf ; }#pragmaMark Uialertviewdelegate-(void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (nsinteger) buttonindex{if(_block! =Nil) {_block (buttonindex,self.content); }}#pragmaMark Uitextviewdelegate-(void) Textviewdidchange: (Uitextview *) textview{self.content=Textview.text;} @end
Call: __weak viewcontroller*weakthis =Self ; Alertviewblock Block= ^ (Nsinteger index,nsstring *content) {__strong Viewcontroller*strongthis =Weakthis; if(Index = =1) {NSLog (@"Determine,--%@", content); }Else if(Index = =0) {StrongThis.showLabel.text=@"Cancel"; } }; Mjyalterview*alterview = [[Mjyalterview alloc] Initwithtitle:@""Message@""Cancelbuttontitle:nil Otherbuttontitles:@"Determine"Clickbutton:block]; [Alterview show];
iOS Development Basics-Fragmentation 22