popViewController 之 同时pop掉2层viewController
项目中有注册和修改密码功能,一旦注册成功就需要跳转到成功的界面,然后成功界面会有相应返回按钮事件,这时候我就需要直接返回我的上上层视图了 开始我用的BLOCK,可是这种已经不能满足我的要求了, (下面功能虽然没有实现,但是可以理解block的简单使用了
项目中有注册和修改密码功能,一旦注册成功就需要跳转到成功的界面,然后成功界面会有相应返回按钮事件,这时候我就需要直接返回我的上上层视图了
开始我用的BLOCK,可是这种已经不能满足我的要求了,
(下面功能虽然没有实现,但是可以理解block的简单使用了)
要求:我有3个视图
视图1为登录界面
视图2为注册界面
视图3为提示成功界面
视图2已经push到了视图1上,接下来就要在视图2里写block了,代码如下
ViewController2 . h
@property (nonatomic,copy) void (^callback)(void);//我的block对象
ViewController2 . m
UIStoryboard *sb=[UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
ViewController3 *vc3=(ViewController3 *)[sb instantiateViewControllerWithIdentifier:@"viewcontroller3"];
/*以上2行是我加载故事版中的视图3*/
vc3.phoneNumber=self.phoneNum.text;//在故事版中如果2个视图之间相互传值,可以采用以上3行代码的形式来传递
void (^myBlock)(void)=^{
[self.navigationController popViewControllerAnimated:YES];
};
[vc3 setCallback:myBlock];//将我的block赋给视图3
[self.navigationController pushViewController:vc3 animated:YES];
以下代码为视图3里面的
ViewController3 . h
@property (nonatomic,copy) void (^callback)(void);
ViewController3 . m
if (self.callback) {
self.callback();
}
[self.navigationController popViewControllerAnimated:YES];
现在来看看我是如何实现的吧(简称面包屑用法)
【这种用法可以让你指定到你想返回的视图中去】根据上述功能,我将此段代码放在了视图3中
NSArray *pushVCAry=[self.navigationController viewControllers];
//下面的pushVCAry.count-3 是让我回到视图1中去
UIViewController *popVC=[pushVCAry objectAtIndex:pushVCAry.count-3];
[self.navigationController popToViewController:popVC animated:YES];
希望对大家有所帮助,讲解的不是太好,大家可以在下方留言给我

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution to Linuxvi not displaying the cursor: 1. Log in to the Linux system and enter the terminal; 2. Display the cursor by executing the "echo-e"\033[?25h"" method. The Linux terminal cursor disappears problem. When I was writing a script in vim today, I suddenly found that the cursor disappeared. This was very uncomfortable. I didn’t know where the editing position was. At first I was looking for vim configuration issues, but later I found that the terminal cursor also disappeared. Only then did we know that the terminal's cursor and vim's cursor are related, so we only need to get out the terminal's cursor. Hide the cursor echo-e"\033[?25l"Show the cursor echo-e&quo

With the popularity of the Internet and email, people increasingly rely on email communication. PHP, as a popular scripting programming language, also provides powerful support for email operations. Among them, IMAP and POP protocols are two commonly used protocols for email operations in PHP. Let's introduce their application in PHP in detail. 1. IMAP protocol The IMAP (Internet Message Access Protocol) protocol is established between the email client and the email server.

In Linux systems, the vi editor is a widely used text editor. For system administrators and programmers, it is crucial to master the skills of vi editor. This article will share some commonly used vi editor skills to help readers improve editing efficiency. Entering the vi editor To enter the vi editor, just type "vi file name" in the Linux terminal. To edit a specific file directly, use "vi filename" on the command line. Switching between command mode and insert mode The vi editor is divided into two modes: command mode and insert mode. In command mode, you can execute various commands to manipulate text; in insert mode, you can enter and edit text content. To switch between the two modes, just press the "Esc" key.

Golang is a programming language with high performance, simplicity, security and strong concurrency support. In the process of developing with Golang, you sometimes encounter some error messages. One of the more common errors is "undefined:heap.Pop". This error usually occurs when using the heap. Let's take a look at how to solve this error. Heap is a very important data structure. Golang provides the heap package to support heap operations.

There are many ways to delete elements from a js array, including using the splice() method, using the pop() and shift() methods, using the delete keyword, and using the filter() method, etc. The following will introduce you to these methods in detail and provide specific code examples. Use the splice() method to delete elements. The splice() method can simultaneously delete elements in the array and return the deleted elements. The syntax is: array.splice(start,delete

1. Three modes and switching ① command line mode ② insert mode (to enter file editing, press ESC to enter bottom line mode) ③ bottom line mode 2. vi mode switching command a--->[Enter the editing state, from the current cursor Insert one character after the current cursor position]A--->[Enter the editing state, insert characters from the end of the current line]i--->[Enter the editing state, insert characters one character before the current cursor position]I--->[Enter Editing state, insert characters from the beginning of the current line]o--->[Enter editing state, insert a line, move the cursor to the beginning of the line and start inserting characters]O--->[Enter editing state, add a blank line before the cursor, move the cursor Start inserting characters at the beginning of the line]ESC--->

1. The vi text editor configuration file is one of the distinctive features of the Linux operating system. Its function is somewhat similar to the registry in the Windows operating system, except that the registry is managed centrally, while the configuration file adopts a decentralized free management method. . 1. Use vi text editor vi is a powerful full-screen text editing tool. It has always been the default text editor for UNIX-like operating systems. vim is an enhanced version of vi text editor (referred to as vi editor). The vi editor has been extended with many practical functions, but it is customary to call vim vi. For ease of use, you can set a command alias and point vi to the vim program (the vim program is used as an example in this article). The specific operations are as follows

Pepe Unchained (PEPU) is not just another meme coin riding the popularity wave; it's a groundbreaking project that aims to redefine the meme coin market with its Layer-2 network.
