如何显示UIActionSheet以确认在导航视图中返回

Dem*_*rpl 0 navigation xcode objective-c uiactionsheet

使用Xcode我有View A导航到View B.

在按下Back UIBarButtonItem时,我正在尝试向用户显示UIActionSheet以确认导航以返回到View A.

在代码中我需要做什么来阻止视图导航回来然后(取决于用户输入)向后移动或留在当前屏幕上?

zah*_*lay 8

以编程方式添加一个后退按钮.

例如.

UIButton *backBtn= [[UIButton alloc] initWithFrame:CGRectMake(0,0,54,30)];
 [backBtn addTarget:self action:@selector(backButtonPressed:)forControlEvents:UIControlEventTouchUpInside];
 UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithCustomView:backBtn];   
[backBtn release];
 [[self navigationItem] setLeftBarButtonItem:backBarButton];
 [backBarButton release];

  //backButtonPressed is the selector for backBtn
Run Code Online (Sandbox Code Playgroud)

然后从该选择器呈现ActionSheet,并根据用户导航到上一个viewController或不.

要导航到上一页,请使用popViewMethod.

`