IOS-problem set-Map-city list

Source: Internet
Author: User

3. MapView-click the city button. A list of available cities is displayed, but it is not reflected when you click the city button. There are no warnings or errors in the program. How can I find this problem? The best way is to use the logic reasoning of Detective thinking. For example, if you want to produce a mobile phone, you need to have dozens of processes (such as running water), and check that a mobile phone is unqualified, which leads to a problem; what should we do if there is a problem? First, we must find the problem, and find the problem to solve it. The key is to find the problem. How can we find the problem? When writing a program, the problem is pointed out by the program when warnings and errors are reported. (when writing a program, we need to have a clear structure, rigorous logic, and brains, try to know the possible problems and restrictions of the written code in advance when writing the Code). I only need to solve it, but when there is no warning or error, how can we locate the problem and solve it? In this example, I wrote a map, and now there is a problem as described above. The first thing I want to know is whether a button is associated or not. Then I will find the corresponding action of the button, // bring up the city list navigation controller-(IBAction) cityAction :( id) sender {NSLog (@ "cityAction = % @", self. navigationController); [self. navigationController presentModalViewController: self. worldCitiesListNavigationController animated: YES];} In this method, we must first obtain self. navigationController, and then get self. worldCitiesListNavigationController, and finally execute the presentModalViewController: animated: method. I will test... I went to test Step 2 first. I printed the methods and saw that they were not executed. The execution sequence was correct. Later, [940: c07] cityAction = <null> found that the first step self. navigationController was not obtained. No navigationController is initialized, and no memory is allocated to navigationController. It is empty. The problem is found. In AppDelegate. m-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {self. window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen] bounds]; self. viewController = [[ViewController alloc] initWithNibName: @ "ViewController" bundle: nil]; self. navigationController = [[UINavigationController alloc] initWithRootViewController: self. viewController]; [self. window addSubview: [navigationController view]; [self. window makeKeyAndVisible]; return YES;}. In this case, click the city button to display the city list.

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.