当我们按回键时没有获得选项卡视图

发布于 2024-11-08 06:35:35 字数 951 浏览 0 评论 0 原文

大家好,

我已经创建了一个带有选项卡视图控制器的测试项目,单击选项卡时,它将转到相应的屏幕(例如屏幕A),当我单击屏幕A中的后退按钮时,它将返回主页,但没有选项卡视图, 类名,

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

以下是后退按钮的可能代码,其中 DataEntry 是我导航到上面代码的

[self.navigationController dismissModalViewControllerAnimated:YES]; 

如果我使用以下代码,它将正常工作&我会使用选项卡返回主页,但它不会运行 viewDidLoad 中更新的代码,因此我需要导航到主页,而不是使用 disstedModalViewController

任何人都可以告诉我当我导航到主页时如何获取 tabView不使用dismissModalViewController的页面

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

就是爱搞怪 2024-11-15 06:36:31

我正在努力理解你的问题,但 viewDidLoad 仅在视图加载时运行:而不是在你返回屏幕 A 时运行:那时它仍然加载。要在每次显示屏幕 A 时运行代码,请查看 viewWillAppear / viewDidAppear http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html

我倾向于以编程方式创建选项卡,而不是使用IB:发生的事情更清楚了。看看这个答案,看看我是如何做到的。
代码中带有 UINavigationController 的 UITabBar

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

指尖凝香 2024-11-15 06:36:28

这是不正确的:

[self.navigationControllerpresentModalViewController:addNavigationControlleranimated:YES];

(这不是你想要的:它将呈现一个模式视图,当你关闭它时,它会发现什么在下面,即您的选项卡)

您应该使用 pushViewController 来显示您的 avController 以便激活后退按钮等等。

看看这个

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文