Ios NavBar + TarBar skills,

Source: Internet
Author: User

Ios NavBar + TarBar skills,

NavBar + TarBar

NavBar + TarBar for iphone Development

1. Change the NavBar color: select the Tint attribute of the Navigation Bar. Select the color.

2. Hide the "back" button: self. navigationItem. hidesBackButton = YES;

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

4. You do not need to use the Navigation created by MainWindow. xib. Custom on each view.

Add the following code to each control page to hide nav:

-(Void) viewWillAppear :( BOOL) animated

{

Self. navigationController. navigationBarHidden = YES; // display "NavBar"

}

Add the Navigation Bar on each control page. Add the required BarButtonItem button.

5. Hide the tarbar upon page Jump:

HomeDetailViewController * detailview = [[HomeDetailViewController alloc] initWithNibName: @ "HomeDetailView" bundle: nil];

Detailview. hidesBottomBarWhenPushed = YES; // hide the tarbar

[Self. navigationController pushViewController: detailview animated: YES];

[Detailview release];

6 page return:

[Self. navigationController popViewControllerAnimated: YES];

7 by default, tabbar is selected as the first view:

TabBarController. selectedIndex = 0;

Others:

8 it is known that the distance between two locations is calculated based on the longitude and latitude:

// The current location is displayed on the map:

MapView. showsUserLocation = YES;

CLLocationManager * locationManager = [[CLLocationManager alloc] init]; // create a location manager

LocationManager. delegate = self; // sets the proxy.

LocationManager. desiredAccuracy = kCLLocationAccuracyBest; // specify the desired precision level as the best precision.

LocationManager. distanceFilter = 1000.0f; // set the distance filter to send updates for any movement.

[LocationManager startUpdatingLocation]; // start Location Manager

MKCoordinateSpan theSpan;

// The smaller the MAP range, 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. longpolling );

// Calculate the distance between two locations based on the longitude and latitude of two points:

CLLocation * location1 = [[CLLocation alloc] initWithLatitude: usrCoordinate. latitude longpolling: usrCoordinate. longpolling] autorelease];

CLLocation * location2 = [[CLLocation alloc] initWithLatitude: 36.676445 longpolling: 117.106793] autorelease];

NSLog (@ "JULI ===%. 0f km", [location1 distanceFromLocation: location2]); // 4502

9. Take the two digits after the decimal point (rounded to five). The output is as follows:

NSLog (@ "%. 02f km", 4478.442312 );

10 call the call API:

[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "tel: // 10010"];

When you call a phone in this way, the iphone interface will stay on the phone interface after the user finishes the call.

The following method can be used to automatically return to the application after the user finishes the call:

UIWebView * callWebview = [[UIWebView alloc] init];

NSURL * telURL = [NSURL URLWithString: @ "tel: 10086"]; // It Looks Like tel: // or tel:

[CallWebview loadRequest: [NSURLRequest requestWithURL: telURL];

// Remember to add to view

[Self. view addSubview: callWebview];

11. Call SMS to send text messages:

[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "sms: // 15315310992"];

12. Call the self-contained browser safari

[[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ http://www.baidu.com];

13 open another program in one program:

First, add URLSchemes to Item0 in URL types in plist to open Item0 input sinaWeibo

Then, [[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "sinaWeibo: // *"];

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

14 double quotation marks escape:

Double quotation marks \"

15. Click the Settings button to change the image or release the source image.

// [Danxuan setImage: [UIImage imageNamed: @ "exercise_option_n.png"] forState: UIControlStateNormal];

// Set the image to be pressed.

// [Danxuan setImage: [UIImage imageNamed: @ "exercise_option_s.png"] forState: UIControlEventTouchDragOutside];

16. determine whether an element exists in the array:

BOOL isValue = [keyArray containsObject: @ "aaa"];

17 Add a button to Nav

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];

[LeftBarButtonItem release]




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.