1: Set the table row with spacing (uitableviewstylegrouped)
1. Set the number of sections, that is, how many cell-(Nsinteger) Numberofsectionsintableview you have: (UITableView *) TableView { return 3;//In Your case, there is 3 cells}2. Returns a cell-(Nsinteger) TableView for each section: (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 = [[UIView alloc] init]; Headerview.backgroundcolor = [Uicolor clearcolor]; return Headerview;} Note: You need to use Indexpath.section to get index instead of indexpath.rowcell.textlabel.text=[nsstring stringwithformat:@ "%@", [array ObjectAtIndex:indexPath.section]];
Instance:
Create the 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:[blsreplenishmentcell class] Forcellreuseidentifier:blsreplenishmentviewcontroller_ Cellidentifier]; [Self.view Addsubview:_mytableview]; Other methods: #pragma mark Uitableviewdatasource and uitableviewdelegate-(cgfloat) TableView: (UITableView *) TableView Heightforheaderinsection: (Nsinteger) section{return 10;} If set to 0 effect will not reach the desired-(cgfloat) TableView: (UITableView *) TableView heightforfooterinsection: (nsinteger) section{RetuRN 1;} -(Nsinteger) Numberofsectionsintableview: (nonnull uitableview *) tableview{return self.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]; return cell;} -(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 the listener to the component [TextField addtarget:self action: @selector (Textfielddidchange:) forControlEvents: uicontroleventeditingchanged];...//The second step, implement the callback function-(void) Textfielddidchange: (ID) Sender {uitextfield *_field = ( Uitextfield *) sender; NSLog (@ "%@,%d", [_field text],_field.text.length);}
4: Real Machine Debug Report
Please verify this 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" typedef void (^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:message D Elegate:self Cancelbuttontitle:cancelbuttontitle otherbuttontitles:otherbuttontitles, nil]; Self.backgroundcolor = [Uicolor whitecolor]; Uiplaceholdertextview *textview = [[Uiplaceholdertextview alloc]init]; textview.delegate=self; Textview.font=[uifont systemfontofsize:15]; TextView. [email protected] "input content"; Textview.layer.bordercolor=[uicolor Graycolor]. Cgcolor; textview.layer.borderwidth=0.5; if (System_version_less_than (@ "7.0"))//When system is IOS7//{//[Testalert Addsubview:textview]; }//else//when the system is IOS8//{[Self Setvalue:textview forkey:@ "Accessoryview"]; } if (self) {_block = block; } return self; } #pragma mark uialertviewdelegate-(void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (Nsinteger) buttonindex{if (_block! = nil) {_block (buttonindex,self.content); }} #pragma mark 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;< C6/>if (index = = 1) { NSLog (@ "OK,--%@", content); } else if (index = = 0) { StrongThis.showLabel.text = @ "Cancel"; } }; Mjyalterview *alterview = [[Mjyalterview alloc] initwithtitle:@ "" message:@ "" Cancelbuttontitle:nil otherButtonTitles: @ "OK" clickbutton:block]; [Alterview show];
6:ios Uilabel Display HTML text (IOS7 or more)
NSString * htmlstring = @ "
Application example (auto height)
if (self.contentlabel==nil) {Self.contentlabel=[[uilabel alloc]init]; Self.contentlabel.textcolor=color_word_gray_1; Self.contentlabel.font=[uifont systemfontofsize:14]; self.contentlabel.numberoflines=0; [Self.contentlabel SizeToFit]; [Self.contentview AddSubview:self.contentLabel]; [Self.contentlabel mas_makeconstraints:^ (Masconstraintmaker *make) {Make.left.mas_equalTo (self.contentView.left). With.offset (Leftspace); Make.right.mas_equalTo (self.contentView.right). With.offset (-leftspace); Make.top.mas_equalTo (Self.lineView.bottom). With.offset (Topspace); }]; } Assignment: nsattributedstring * attrstr = [[Nsattributedstring alloc] Initwithdata:[model.content Datausingencoding:nsuni Codestringencoding] options:@{Nsdocumenttypedocumentattribute:nshtmltextdocumenttype} documentAttributes:nil Error:nil]; Self.contentLabel.attributedText= Attrstr;
iOS Development Basics-Fragmentation 22