开发者

viewController management programmatically

I have a problem about viewController. I created a program What is viewController based applicaiton. There is 4 button on mainViewController. I used this code for calling mainviewController

-(void) applicationDidFinishLaunching:(UIApplication *)application{   

 self.window.rootViewController = self.viewController;  
[self.window makeKeyAndVisible];
}

Then click to any button on homePage , I go to the other viewController. This code for call another viewController belong

-(IBAction)clickCalendarButton{
    calendarButton.selected=YES;
    [calendarButton
     setImage:[UIImage imageNamed:@"afvalkalender_pressed.png"] forState:(UIControlStateHighlighted+UIControlStateSelected)];
    GarbageCalendar *garbageCalendar = [[开发者_高级运维GarbageCalendar alloc] initWithNibName:@"GarbageCalendar" bundle:nil];
    [self presentModalViewController:garbageCalendar  animated:YES];
}

And then I want to go home page from another viewController. But I didn' go home page viewController.


Create button on detail view controller, which calls something like this:

- (IBAction)goBack {
   [self dismissModalViewControllerAnimated:YES];
}


If you want to keep your current UI design, based on modal view controllers, then I think you should ensure that your other view controllers have got a button that does the dismiss of the view. Say, e.g., a "Back" or "Done" button. When you click on that button, a delegate method is called that executes: [self dismissModalViewControllerAnimated:YES];

Look also at this document for more info, section "Dismissing a Modal View Controller".

If you would like to consider alternative approaches to your UI, you could look into using a UINavigationController, which would make your life a little bit easier with navigating back from one controller to another.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜