简体   繁体   English

当前没有后退按钮的ViewController

[英]Present ViewController without Back button

I'm having an annoying problem which takes the best off me :< 我遇到一个烦人的问题,这使我受益匪浅:<

I've got 3 view controllers, one to show an advertisement in detail which also has a toolbar. 我有3个视图控制器,其中一个用于详细显示广告,还具有一个工具栏。 Now what I want is, if the user presses the facebook icon on my toolbar in the first view it has to perform a check. 现在我想要的是,如果用户在第一个视图中按我的工具栏上的facebook图标,则必须执行检查。 If the check turns out false it needs to go to a 2nd view which shows a login screen. 如果检查结果为假,则需要转到显示登录屏幕的第二视图。 If the user logs in here it has to go to a 3rd screen which shows a simple input + button to update their status. 如果用户在此处登录,则必须转到第三个屏幕,该屏幕显示一个简单的输入+按钮以更新其状态。

When the user is at this third screen there should be a button "Back", but this button shouldn't bring them back to View2 but it should bring them back to View1 (the advertisement detail screen). 当用户在第三个屏幕上时,应该有一个“返回”按钮,但是此按钮不应将其带回到View2,而应将其带回到View1(广告详细信息屏幕)。

I figured that I wanted to show the 2nd screen (if check turns false) without pushing it but keeping the NavigationBar + TabBar presented. 我认为我想显示第二个屏幕(如果检查变为假),而不要按下它,而是保持显示NavigationBar + TabBar。 I added some screenshots to clarify. 我添加了一些屏幕截图来阐明。

First view 第一视角 第一视图,详细的广告信息

Second view 第二种观点 如果用户单击Facebook图标,但该用户未知,则将显示此视图。如果用户是已知的,则将显示视图3 I want this view to be presented without using PushViewController but keep the NavigationBar and TabBar. 我希望在不使用PushViewController的情况下显示此视图,但要保留NavigationBar和TabBar。

Third View 第三观点 第三视图,如果按Back,则必须显示View1

I hope this is enough information, hopefully someone can help me. 我希望这是足够的信息,希望有人可以帮助我。

Thanks in advance! 提前致谢!

Perhaps the most natural thing to do here is to present the login view controller modally. 也许在这里最自然的事情是模态地呈现登录视图控制器。 When the user has logged in successfully, the first controller can then push the third view controller onto the navigation stack. 当用户成功登录后,第一个控制器可以将第三个视图控制器推入导航堆栈。 This way, the back button will lead directly back to the first view controller, and the user will understand why. 这样,后退按钮将直接引回到第一个视图控制器,并且用户将理解原因。

So if we have three UIVIewControllers: 因此,如果我们有三个UIVIewControllers:

DetailViewController FacebookLoginViewController UpdateViewController DetailViewController FacebookLoginViewController UpdateViewController

We have two viable options: 我们有两个可行的选择:

1) Upon successful login...pop the current LoginViewController and then push the UpdateViewController 1)成功登录后...弹出当前的LoginViewController,然后按UpdateViewController

PopViewController(detailViewController, false);
PushViewController(updateViewController, true);

2) Present the login Modally and simply present the UpdateViewController 2)模态地显示登录名,并简单地显示UpdateViewController

PushModalViewController(loginViewController, true);

//ascertain result of login

if(IsLoggedIn) {
    PushViewController(updateViewController, true);
}

Try to pop the current view controller (without animation i guess) before pushing the new one. 在推送新的视图控制器之前,尝试弹出当前的视图控制器(我猜没有动画)。 If there is only one view controller in the navigation stack no back button will be shown. 如果导航堆栈中只有一个视图控制器,则不会显示后退按钮。

Haven't used Monotouch but i guess something like this: 还没有用过Monotouch,但是我猜是这样的:

this.NavigationController.PopViewControllerAnimated(false);
this.NavigationController.PushViewController(newViewController, true);

But as Caleb suggests it's probably better figure out a way that fits the normal navigation behaviours instead of hacking around it. 但是正如Caleb所建议的那样,最好是找到一种适合常规导航行为的方法,而不是去破解它。

consider the following view push logic. 考虑以下视图推送逻辑。

if (!login) {
    LoginViewController *lvc = [[[LoginViewController alloc] init] autorelease];
    [self.navigationController pushViewController:lvc];
}
else {
    ThirdViewController *tvc = [[[ThirdViewController alloc] init] autorelease];
    [self.navigationController pushViewController:tvc];
}

It is : create and push the view controller when it is needed. 它是:在需要时创建并推送视图控制器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SWRevealViewController中不存在后退按钮 - Back Button not present in SWRevealViewController 目前ViewController Segue Transition没有故事板[Swift] - Present ViewController Segue Transition Without Storyboard [Swift] TabBarcontroller之后如何在Viewcontroller上启用后退按钮 - How to enable Back Button on Viewcontroller after TabBarcontroller UIImage和“后退”按钮都出现在我的viewController中 - Both a UIImage and a “back” button appearing in my viewController 将ViewController嵌入到NavigationController中没有“返回”按钮 - Embedding a ViewController in a NavigationController does not have “Back” button 按下CollectionViewCell内部的按钮后如何呈现ViewController - How to present a ViewController after pressing a button inside of a CollectionViewCell 单击后退按钮时,ViewController标题颜色将更改更改颜色 - ViewController title color will change change color when back button clicked 推送视图控制器不为后退按钮取上一个的标题 - Pushed viewcontroller not taking on title of previous one for back button 模态ViewController消失后,iOS 7自定义后退按钮消失 - iOS 7 Custom Back Button disappears after modal ViewController disappeared 当没有后退按钮时,向 UINavigationController 添加左栏按钮项 - Add a left bar button item to UINavigationController when no back button is present
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM