【问题标题】:Session is restarted when using the alert view in iphone?在iphone中使用警报视图时会话重新启动?
【发布时间】:2010-02-18 19:56:48
【问题描述】:

我是 iphone 开发的新手。我正在创建一个地图应用程序。现在我遇到了警报视图的问题。要查看警报视图在模拟器中的显示方式,我在“视图确实加载”中添加了一个警报视图方法。当我单击登录页面中的按钮时,它导航到另一个视图(显示警报视图的位置)当我运行应用程序时,在控制台窗口中,我可以看到会话在登录页面初始启动后再次启动。

用于显示警报

 UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Current Location" message:@"Show Current Location?" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK"];
    [alert show];

在控制台窗口中

  [Session started at 2010-02-18 15:57:12 +0530.]

[Session started at 2010-02-18 15:57:23 +0530.]
GNU gdb 6.3.50-20050815 (Apple version gdb-967) (Tue Jul 14 02:11:58 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 604.
(gdb) 

我只是想查看警报视图而不对单击确定或取消按钮执行任何操作。请帮帮我。请指导我。谢谢。

【问题讨论】:

    标签: iphone uialertview


    【解决方案1】:

    这只是调试器 (gdb) 的初始化。

    如果调试器未在应用启动时启动(如果您只是构建并运行而不是构建和调试,则会出现这种情况),调试器将在应用遇到问题时启动并初始化。

    您在此处遇到的问题在于您的警报视图初始化行。在最后一个参数之前一切都很好:otherButtonTitles: - 注意标题上的复数,而不是标题。这意味着该参数采用一个以 nil 结尾的项目列表 - 这也在文档中进行了说明。

    你应该修改你的代码,使参数以 nil-terminated 结尾:

     UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Current Location" message:@"Show Current Location?" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
    

    【讨论】:

    • 谢谢。它工作正常。我应该在哪里编写应该加载当前位置的单击“ok”事件的代码
    • 这是一个单独的主题,因此您应该为此提出一个新问题。提示是查看UIAlertViewDelegate 协议。
    猜你喜欢
    • 2014-07-09
    • 2023-03-11
    • 1970-01-01
    • 2019-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多