NavBar and TarBar use tips for iOS development

Source: Internet
Author: User

1 Change navbar color: Check the Tint property of navigation Bar. Select a color.

2 Hide "Back" button: Self.navigationItem.hidesBackButton = YES;

3 Hide "NavBar": Self.navigationController.navigationBarHidden = YES;

4 You can create a navigation without mainwindow.xib. Customize on each view.

You need to add each control page with the following code to hide the nav:
-(void) Viewwillappear: (BOOL) animated
{
Self.navigationController.navigationBarHidden = yes;//display "NavBar"
}
Then on each control page xib yourself add navigation Bar. Add the desired Barbuttonitem button.


5 page Jump Hide TarBar:
Homedetailviewcontroller *detailview = [[Homedetailviewcontroller alloc] initwithnibname:@ "HomeDetailView" bundle: NIL];
detailview.hidesbottombarwhenpushed = yes;//Hidden TarBar
[Self.navigationcontroller Pushviewcontroller:detailview Animated:yes];
[DetailView release];

6 page back:
[Self.navigationcontroller Popviewcontrolleranimated:yes];

7 Default Check Tabbar is the first view:
tabbarcontroller.selectedindex= 0;


Other:
8 The distance between the two places is known to calculate the latitude and longitude:
The map shows the current location:
Mapview.showsuserlocation=yes;
Cllocationmanager *locationmanager = [[Cllocationmanager alloc] init];//Create location Manager
locationmanager.delegate=self;//Setting up Agents
LOCATIONMANAGER.DESIREDACCURACY=KCLLOCATIONACCURACYBEST;//Specifies the required precision level for the best precision
locationmanager.distancefilter=1000.0f;//set the distance filter to send updates for any move
[Locationmanager startupdatinglocation];//start Position Manager
Mkcoordinatespan Thespan;
The smaller the map, the more accurate it is.
thespan.latitudedelta=0.05;
thespan.longitudedelta=0.05;
Mkcoordinateregion theregion;
Theregion.center=[[locationmanager location] coordinate];
Theregion.span=thespan;
[Mapview setregion:theregion];
[Locationmanager release];

Mkuserlocation *usrloc=mapview.userlocation;
Cllocationcoordinate2d usrcoordinate=usrloc.location.coordinate;
NSLog (@ "la==%f lo==%f", usrcoordinate.latitude,usrcoordinate.longitude);

The latitude and longitude of two points are known and the distance between the two places is calculated:
Cllocation *location1 = [[[Cllocation alloc] InitWithLatitude:usrCoordinate.latitude Longitude: Usrcoordinate.longitude] autorelease];
Cllocation *location2 = [[[Cllocation alloc] initwithlatitude:36.676445 longitude:117.106793] autorelease];
NSLog (@ "juli====%.0f km", [Location1 Distancefromlocation:location2]);//4502


9 take the decimal point two bits (rounded), output:
NSLog (@ "%.02f km", 4478.442312);

10 Calling the Call API:
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "tel://10010"];
When you make a call this way, the iphone interface stays on the phone interface when the user ends the call.
This allows users to automatically return to the app after the call is completed:
Uiwebview*callwebview =[[uiwebview alloc] init];
Nsurl *telurl =[nsurl urlwithstring:@ "tel:10086"];//looks like tel://or Tel: All right
[Callwebview loadrequest:[nsurlrequest Requestwithurl:telurl];
Remember to add to the view
[Self.view Addsubview:callwebview];

11 Call SMS to send SMS:
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "sms://15315310992"];

12 calling your own browser safari
[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "http://www.baidu.com"];

13 Open Another program in one program:
First: plist Add the URL types point open inside the Item0 add urlschemes open Item0 input Sinaweibo
And then where it needs to be called: [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@ "sinaweibo://*"];

Https://itunes.apple.com/cn/app/qq-2012/id444934666?mt=8

14 Double Quote escape:
Use \ "to denote double quotation marks

15 Set Button Press to change picture release or original
[Danxuan setimage:[uiimage imagenamed:@ "Exercise_option_n.png"] forstate:uicontrolstatenormal];
This is a set of pressed pictures, release is the picture above
[Danxuan setimage:[uiimage imagenamed:@ "Exercise_option_s.png"] forstate:uicontroleventtouchdragoutside];

16 determine if an element exists in the array:
BOOL isvalue=[keyarray containsobject:@ "AAA"];

+ Nav Add button
UIButton *btnback = [Abutil createnavigationctrollerroundedrectbtn:localized (@ "Cancel")]; 
    [Btnback addtarget:self 
                 Action: @selector (Tapleftbarbutton)  
       Forcontrolevents:uicontroleventtouchupinside];  
    Uibarbuttonitem *leftbarbuttonitem = [[ Uibarbuttonitem alloc] initwithcustomview:btnback];  
    Self.navigationItem.leftBarButtonItem = Leftbarbuttonitem;  
    [Btnback release]; &NBSP
    [leftbarbuttonitem release]

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.