开发者

not getting tab view when we press back

开发者 https://www.devze.com 2023-03-06 19:38 出处:网络
hii every one i have created a test project with tab view controller, on click of a tab it will goto that coresponding开发者_如何学编程 screen(say screen A) when i click back button in screen A it w

hii every one

i have created a test project with tab view controller, on click of a tab it will goto that coresponding开发者_如何学编程 screen(say screen A) when i click back button in screen A it will come back to main page but with out tabView, following is may code for back button where DataEntry is a class name to where i am navigating

DataEntry *avController;
UINavigationController *addNavigationController;


if(avController == nil)
        avController = [[DataEntry alloc] initWithNibName:nil bundle:nil];

    if(addNavigationController == nil)
        addNavigationController = [[UINavigationController alloc] initWithRootViewController:avController];
    //avController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self.navigationController presentModalViewController:addNavigationController animated:YES];

insted of the above code if i use following code

[self.navigationController dismissModalViewControllerAnimated:YES]; 

it will work fine & ill get back to main page with tabs , but it wont run the updated code which is in the viewDidLoad so i need to navigate to the main page insted of using dismissModalViewController

can any one tell me how can i get tabView when i navigate to the main page with out using dismissModalViewController


this is not correct:

[self.navigationController presentModalViewController:addNavigationController animated:YES];

(this is not what you mean to have: it will present a modal view, when you dismiss it, it will uncover what was below, i.e. your tab)

you should use pushViewController to show your avController so that the back button is activated and so on.

look at this.


I'm struggling a little to understand your problem, but viewDidLoad only runs when the view loads: not when you come back to screen A : its still loaded then. To run code each time screen A is displayed, take a look at viewWillAppear / viewDidAppear http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html

I tend to create tabs programatically rather than using the IB: its clearer whats going on. Take a look at this answer to show how I do it. UITabBar with UINavigationController in code

0

精彩评论

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