简体   繁体   English

设置AlertViewStyle时应用程序崩溃

[英]Application crash when setting alertviewstyle

I'm trying to use the alertviewstyle to use the text input from a user. 我正在尝试使用alertviewstyle使用来自用户的文本输入。 When I show the alertview without changing the style, it works. 当我在不更改样式的情况下显示alertview ,它将起作用。

When I change the style to UIAlertViewStylePlainTextInput I get this error: 当我将样式更改为UIAlertViewStylePlainTextInput此错误:

error: address doesn't contain a section that points to a section in a object file. 错误:地址不包含指向目标文件中某个部分的部分。

I am using the follow code: 我正在使用以下代码:

nameAlertView =
    [[UIAlertView alloc] initWithTitle:[langFile objectForKey:@"sequenceTitel"]
                               message:[langFile objectForKey:@"sequenceTitel"]
                              delegate:self
                     cancelButtonTitle:[langFile objectForKey:@"cancel"]
                     otherButtonTitles:[langFile objectForKey:@"save"], nil];

nameAlertView.alertViewStyle = UIAlertViewStylePlainTextInput;

[nameAlertView show];
[nameAlertView release];

Edit 编辑

I'm using iOS 5.1 and I had the follow feedback from debugger: 我正在使用iOS 5.1,并且收到了调试器的以下反馈:

Training Tool(2332,0x3f080d98) malloc: * mmap(size=1342177280) failed (error code=12) 培训工具(2332,0x3f080d98)malloc: * mmap(size = 1342177280)失败(错误代码= 12) error: can't allocate region * * set a breakpoint in malloc_error_break to debug 错误:无法分配区域* *在malloc_error_break中设置断点进行调试


It's strange because sometimes it works when completing the same actions in my view 这很奇怪,因为有时在我认为完成相同的操作时它会起作用

You'll find out what the object is when you break in the debugger. 在调试器中中断时,您将发现对象是什么。 Just look up the call stack and you will find where you free (or release) it. 只需查找调用堆栈,您就会找到将其释放(或释放)的位置。 That will tell you which object it is. 这将告诉您它是哪个对象。

The easiest way to set the breakpoint is to: 设置断点的最简单方法是:

Goto Run -> Show -> Breakpoints (Alt-Command-B)
Scroll to the bottom of the list and add the symbol malloc_error_break

I've met the same problem when setting the deployment target to 4.X since this style property is only supported in ios5. 将部署目标设置为4.X时,我遇到了同样的问题,因为仅ios5支持此样式属性。 Make sure "deployment target" is 5.1 even if your device is ios 5.1. 即使您的设备是ios 5.1,也请确保“部署目标”为5.1。

显示后不要立即释放UIAlertView,而是在委托回调中释放它。

I encountered the same problem today, I searched for this thing , it solves my problem, I hope you can answer confusion. 我今天遇到了同样的问题,我搜索了这个东西 ,它解决了我的问题,希望您能回答困惑。 It means that because before setting alert.alertviewstyle, your keyboard is open resulting in the problem, when I turn off the keyboard before setting alertviewstyle, and it's normal. 这意味着,因为在设置alertview.alertviewstyle之前,您的键盘是打开的,所以在设置alertviewstyle之前我关闭键盘时会出现问题,这是正常的。 This is the iOS 9 before a bug, iOS 9 fix it. 这是iOS 9之前的一个错误,iOS 9对其进行了修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM