31-40 (PHC file, Uiapplication,info.plis, monitor return button, format date, OpenURL)

Source: Internet
Author: User
Tags dateformat

31. Monitor Return button

32. Automatically scroll the table to the last row

33. Formatting dates

34. Return header headings for each group to be displayed

35.info.plist Common Settings

36.PHC file

37.UIApplication

Common Properties of 38.UIApplication

The status bar in 39.ios7

40.openURL

{

A qualified programmer would not write a program like "Destroy the Earth,"

}

31. Click the return button (the button at the bottom right corner of the keyboard) will be called, when using this method, to respect the Uitextfielddelegate protocol,
-(BOOL) Textfieldshouldreturn: (Uitextfield *) textfield{
[Self addMessage:textField.text type:mjmessagetypeme];//1. Send a message yourself
NSString *reply = [self replaywithtext:textfield.text];//2. Automatically reply to a message
[Self addmessage:reply type:mjmessagetypeother];
Self.inputView.text = nil;//3. Clear text
Return yes;//returns YES
}

32. Automatically scroll the table to the last row
Nsindexpath *lastpath = [Nsindexpath indexpathforrow:self.messageframes.count-1 insection:0];
[Self.tableview Scrolltorowatindexpath:lastpath Atscrollposition:uitableviewscrollpositionbottom Animated:YES];

33. Formatting dates
NSDate *now = [NSDate Date];
NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
Fmt.dateformat = @ "hh:mm";
NSDate---> NSString
NSString---> NSDate
Fmt.dateformat = @ "Yyyy-mm-dd HH:mm:ss";
2014-08-09 15:45:56
09/08/2014 15:45:56
Msg.time = [FMT Stringfromdate:now];


34. Return header headings for each group to be displayed
-(UIView *) TableView: (UITableView *) TableView viewforheaderinsection: (nsinteger) Section
{
1. Creating a Header control
Headerview *header = [Headerview Headerviewwithtableview:tableview];
Header.delegate = self;
2. Set data to header (pass model to header)
Header.group = Self.groups[section];
return header;
}

+ (Instancetype) Headerviewwithtableview: (UITableView *) TableView
{
static nsstring *id = @ "header";
Headerview *header = [TableView dequeuereusableheaderfooterviewwithidentifier:id];  
if (header = = nil) {
Header = [[Headerview alloc] initwithreuseidentifier:id];
}
Return header;
}

-(ID) Initwithreuseidentifier: (NSString *) reuseidentifier//in this initialization method, the frame\bounds of Headerview has no value
{
if ( self = [Super Initwithreuseidentifier:reuseidentifier]) {
//Add child control
Nameview.contenthorizontalalignment = UI controlcontenthorizontalalignmentleft;//set the contents of the button left-justified
Nameview.titleedgeinsets = Uiedgeinsetsmake (0, 10, 0, 0);//settings    The inner margin of the button
Nameview.contentedgeinsets = uiedgeinsetsmake (0, 0, 0);
[Nameview addtarget:self Action: @selector (Nameviewclick) forcontrolevents:uicontroleventtouchupinside];
NameView.imageView.contentMode = uiviewcontentmodecenter;//The content mode of the ImageView inside the Set button is centered
nameView.imageView.cl Ipstobounds = no;//The content beyond the border does not need to be clipped
}
return self;
}

-(void) layoutsubviews//is called when a control's frame changes, typically in this case the child controls inside the layout (set the child control's frame)
{
[Super layoutsubviews];//Be sure to call the Super method
1. Set the frame of the button
Self.nameView.frame = Self.bounds;
2. Set the frame of the number of friends
CGFloat County = 0;
CGFloat counth = self.frame.size.height;
CGFloat COUNTW = 150;
CGFloat countx = SELF.FRAME.SIZE.WIDTH-10-COUNTW;
Self.countView.frame = CGRectMake (Countx, county, COUNTW, Counth);
}

-(void) didmovetosuperview//when a control is added to the parent control, it is called
{
if (self.group.opened) {
Self.nameView.imageView.transform = Cgaffinetransformmakerotation (m_pi_2);
} else {
Self.nameView.imageView.transform = cgaffinetransformmakerotation (0);
}
}

-(void) Willmovetosuperview: (UIView *) newsuperview//called when a control is about to be added to the parent control
{ }


35.info.plist Common Settings
After building a project, you will see a "project name-info.plist" file under the supporting Files folder, which is very important for the project to do some run-time configuration, so it cannot be deleted.
In the project created by the older version of Xcode, the profile name is called "Info.plist"
Other plist files in the project cannot have the word "Info", or they will be mistaken for the "info.plist" that is very important in the legend.
There is also a infoplist.strings file in the project that is related to localization of info.plist files
Common Properties
Localiztion native Development Region (cfbundledevelopmentregion)-Localization related
Bundle Display Name (cfbundledisplayname)-a program that displays the names after installation, limited to 10-12 characters, and if exceeded, will be displayed abbreviated names
Icon file (cfbundleiconfile)-app icons name, typically icon.png
Bundle version (cfbundleversion)-The version number of the application, which needs to be increased each time a new version is posted to the App Store
Main Storyboard file base name (nsmainstoryboardfile)-the name of the primary storyboard
Bundle identifier (cfbundleidentifier)-Unique identification of the project, deployed to the real machine

36.PHC file
The project's supporting files folder has a "project name-prefix.pch" file, which is also a header file
The contents of the PCH header file can be shared and accessed by all other source files in the project
In general, some global macros are defined in the PCH file
Add the following preprocessing directives in the PCH file, and then use the log (...) in your project. To output the log information, the NSLog statement can be removed at once when the application is published (debug mode is defined)
#ifdef DEBUG
#define LOG (...) NSLog (__va_args__)
#else
#define LOG (...)/* */
#endif

37.UIApplication
UIApplication objects are symbols of the application
Each application has its own UIApplication object, and it is a singleton
This singleton object can be obtained by [UIApplication Sharedapplication]
The first object created after an iOS program is started is a UIApplication object
Use the UIApplication object to perform some application-level operations

Common Properties of 38.UIApplication
@property (nonatomic) Nsinteger applicationiconbadgenumber;//Set the red reminder number in the upper right corner of the application icon
@property (nonatomic,getter=isnetworkactivityindicatorvisible) BOOL networkactivityindicatorvisible;//Sets the visibility of the networking indicator

The status bar in 39.ios7
Starting with IOS7, the system provides 2 ways to manage the status bar
1. Through Uiviewcontroller management (each uiviewcontroller can have their own different status bar)
2. Through UIApplication Management (the status bar of an application is managed uniformly by it)
In IOS7, by default, the status bar is managed by Uiviewcontroller, and Uiviewcontroller can easily manage the visibility and style of the status bar by implementing the following methods
-(Uistatusbarstyle) Preferredstatusbarstyle; Style of the status bar
-(BOOL) Prefersstatusbarhidden; Visibility of the status bar

40.openURL
UIApplication *app = [UIApplication sharedapplication];
[App Openurl:[nsurl urlwithstring:@ "tel://10086"]];//call
[App Openurl:[nsurl urlwithstring:@ "sms://10086"]];//texting
[App Openurl:[nsurl urlwithstring:@ "Mailto://[email protected]"]];//email
[App Openurl:[nsurl urlwithstring:@ "http://ios.itcast.cn"]];//open a Web resource

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.