2012-09-10 24 views
1

我試圖使用alertviewstyle來使用用戶的文本輸入。 當我在不改變樣式的情況下顯示alertview時,它可以工作。設置alertviewstyle時的應用程序崩潰

當我改變風格UIAlertViewStylePlainTextInput我得到這個錯誤:

error: address doesn't contain a section that points to a section in a object file.

我使用的後續代碼:

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]; 

編輯

我使用的是iOS 5.1並且我有來自調試器的跟隨反饋:

Training Tool(2332,0x3f080d98) malloc: * mmap(size=1342177280) failed (error code=12) error: can't allocate region ** set a breakpoint in malloc_error_break to debug


很奇怪,因爲在我看來,在完成相同的動作時,有時它的工作原理

+0

你確定langFile有足夠的數據嗎? –

+0

我確定,這是langFile中的一個問題 –

+0

當我使用其他文本@「文本」時,它就是一樣! – Thomas

回答

0

你會發現對象是什麼,當你在調試器打破。只需查看調用堆棧,就可以找到你釋放(或釋放)的地方。這將告訴你它是哪個對象。

設置斷點最簡單的方法是:

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

這很奇怪。因爲有時它在我的視圖中完成相同的操作時有效,有時它不會。 – Thomas

0

部署目標設置爲4.X的時候,因爲這種風格屬性在iOS5中唯一支持我遇見了同樣的問題。確保即使您的設備是ios 5.1,「部署目標」也是5.1。

0

不要在顯示它後立即釋放UIAlertView。請在委託回調中釋放它。

0

我今天遇到同樣的問題,我搜索了this thing,它解決了我的問題,希望你能回答困惑。 這意味着,因爲在設置alert.alertviewstyle之前,您的鍵盤是打開的,導致出現問題,當我在設置alertviewstyle之前關閉鍵盤時,這是正常的。 這是iOS 9之前的一個bug,iOS 9修復了它。

相關問題