标签: dismiss

从DialogFragment接收结果

我正在使用DialogFragments做很多事情:从列表中选择项目,输入文本.

将值(即字符串或列表中的项)返回给调用活动/片段的最佳方法是什么?

目前我正在制作调用活动实现DismissListener,并为DialogFragment提供对活动的引用.然后,Dialog调用OnDimissactivity中的方法,activity将从DialogFragment对象中获取结果.非常混乱,因为DialogFragment失去对活动的引用,它不能用于配置更改(方向更改).

谢谢你的帮助.

android dialog fragment dismiss android-fragments

227
推荐指数
8
解决办法
11万
查看次数

在对话框外面按下时如何关闭DialogFragment?

我正在使用a DialogFragment,虽然我已成功设置图像以在关闭时关闭(即关闭)对话框,但当用户点击对话框外的任何地方时,我很难找到解除对话框的方法,就像它一样正常的对话.我以为会有某种

dialogFragment.setCanceledOnTouchOutside(true);
Run Code Online (Sandbox Code Playgroud)

打电话,但我没有在文档中看到.

这有可能DialogFragment吗?或者我在错误的地方寻找?我尝试拦截"父母"活动中的触摸事件,但除了没有得到任何触摸事件外,它对我来说似乎不对.

android fragment dismiss

75
推荐指数
5
解决办法
4万
查看次数

防止用户解除通知

某些应用程序的通知无法通过滑动来解除.

我该如何管理这种行为?

notifications android dismiss android-notifications

59
推荐指数
2
解决办法
2万
查看次数

单个函数来关闭所有打开的视图控制器

我有一个应用程序,它是一个单一的视图应用程序 我有一个导航控制器链接到根视图控制器中的所有子控制器.

在每个子控制器中,我都有一个注销按钮.我想知道我是否可以使用一个可以调用的功能,这将解除所有已经打开的控制器,无论当用户按下注销时哪个控制器当前打开?

我的基本开始:

func tryLogout(){
     self.dismissViewControllerAnimated(true, completion: nil)
     let navigationController = UINavigationController(rootViewController: UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("LoginViewController") )
     self.presentViewController(navigationController, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

我正在寻找执行此任务的最有效的内存方式.我将我的注销函数放在一个单独的utils文件中,但是我不能使用self.而且我仍然知道要动态解除哪些控制器的问题.

已建议更新 Pop到根视图控制器.所以我的尝试是这样的:

func tryLogout(ViewController : UIViewController){
     print("do something")
     dispatch_async(dispatch_get_main_queue(), {
         ViewController.navigationController?.popToRootViewControllerAnimated(true)
         return
     })
 }
Run Code Online (Sandbox Code Playgroud)

这是实现我追求目标的最佳途径吗?

uiviewcontroller dismiss ios swift

48
推荐指数
6
解决办法
6万
查看次数

iPhone - 关闭多个ViewControllers

我有一个很长的View Controllers层次结构;

在第一个View Controller中我使用此代码:

SecondViewController *svc = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self presentModalViewController:svc animated:YES];    
[svc release];
Run Code Online (Sandbox Code Playgroud)

在第二个View Controller中,我使用以下代码:

ThirdViewController *tvc = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
[self presentModalViewController:tvc animated:YES];    
[tvc release];
Run Code Online (Sandbox Code Playgroud)

等等.

所以有一段时间我有很多View Controllers,我需要回到第一个View Controller.如果我一次回来一步,我会在每个View Controller中使用这段代码:

[self dismissModalViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)

如果我想直接从第六个View Controller返回到第一个,我必须做什么才能立即解除所有控制器?

谢谢

iphone uiviewcontroller dismiss

45
推荐指数
6
解决办法
4万
查看次数

如何解除android中的AlertDialog

我创建了包含4个按钮的AlertDialog

OptionDialog = new AlertDialog.Builder(this);
        OptionDialog.setTitle("Options");
        LayoutInflater li = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = li.inflate(R.layout.options, null, false);
        background = (Button) v.findViewById(R.id.bkgSpinnerLabel);
        SoundVib = (Button) v.findViewById(R.id.SoundVibSpinnerLabel);

        OptionDialog.setView(v);
        OptionDialog.setCancelable(true);
        OptionDialog.setNeutralButton("Ok",
                new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface arg0, int arg1) {
                    }
                });
        background.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                SetBackground();
             // here I want to dismiss it after SetBackground() method 
            }
        });


        SoundVib.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent soundVibIntent = new Intent(SebhaActivity.this, EditPreferences.class);
                startActivity(soundVibIntent);
            }
        });

        OptionDialog.show();
Run Code Online (Sandbox Code Playgroud)

我想在SetBackground()方法之后解雇它,我该怎么做呢?提前致谢.

android dismiss android-alertdialog

44
推荐指数
4
解决办法
9万
查看次数

同时关闭多个视图控制器

我正在使用SpriteKit制作游戏.我有3个viewControllers:选择level vc,game vc和win vc.游戏结束后,我想显示win vc,然后如果我按下win vc上的OK按钮,我想解雇win vc和游戏vc(从堆栈中弹出两个视图控制器).但我不知道怎么做,因为如果我打电话

self.dismissViewControllerAnimated(true, completion: {})    
Run Code Online (Sandbox Code Playgroud)

win vc(堆栈顶部)被解雇,所以我不知道在哪里再次调用它来解雇游戏vc.有没有办法在不使用导航控制器的情况下解决这个问题?

这是第一个VC :(请注意以下以"//"开头的评论)

class SelectLevelViewController: UIViewController { // I implemented a UIButton on its storyboard, and its segue shows GameViewController
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}
Run Code Online (Sandbox Code Playgroud)

这是第二个VC:

class GameViewController: UIViewController, UIPopoverPresentationControllerDelegate {
    var scene: GameScene!
    var stage: Stage!

    var startTime = NSTimeInterval()
    var timer = NSTimer()
    var seconds: Double = 0
    var timeStopped = false

    var score = 0

    @IBOutlet weak var targetLabel: UILabel!
    @IBOutlet var displayTimeLabel: UILabel! …
Run Code Online (Sandbox Code Playgroud)

viewcontroller dismiss ios swift

38
推荐指数
6
解决办法
3万
查看次数

如何解雇AlertDialog.Builder?

在下面的代码中,如何关闭警告框?我不想导致内存泄漏.我在alertDialog上尝试了.dismiss(),但是没有用......谢谢

// User pressed the stop button
public void StopMsg_button_action(View view){
    final EditText password_input = new EditText(this); // create an text input field
    password_input.setHint("Enter Password"); // put a hint in it
    password_input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); // change it to password type

    AlertDialog.Builder alertDialog = new Builder(this); // create an alert box
    alertDialog.setTitle("Enter Password"); // set the title
    alertDialog.setView(password_input);  // insert the password text field in the alert box
    alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { // define the 'OK' button
        public void onClick(DialogInterface dialog, …
Run Code Online (Sandbox Code Playgroud)

memory alert android dialog dismiss

29
推荐指数
5
解决办法
6万
查看次数

如何知道Android中的对话框是否被解除?

如果对话框被解除,我想为我的背景做一些事情.所以我想知道对话框是否被解雇

android dialog dismiss

27
推荐指数
2
解决办法
2万
查看次数

一次解除多个模态视图控制器?

所以有一个带有三个视图控制器的堆栈,其中A是根,B是第一个模态视图控制器,C是第三个模态vc.我想立刻从C到A.我已经尝试过这个解决方案来解雇.它确实有效但不是以正确的方式.也就是说,当最后一个视图控制器被解除时,它将在显示第一个视图控制器之前完全显示第二个视图控制器.我正在寻找的是一种从第三个vc到第一个vc的方法在一个不错的动画中没有注意到第二个视图.任何有关这方面的帮助都非常有用.

iphone modal-dialog uiviewcontroller dismiss

21
推荐指数
1
解决办法
8572
查看次数