在iphone中使用警报视图时重启会话?

时间:2010-02-18 10:31:35

标签: iphone uialertview

我是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) 

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

1 个答案:

答案 0 :(得分:1)

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

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

您遇到的问题出在警报视图初始化行中。一切都很好,直到最后一个参数:otherButtonTitles: - 注意标题上的复数,而不是标题。这意味着该参数采用未终止的项目列表 - 这也在文档中说明。

你应该修改你的代码,使参数像nil一样终止:

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