2012-04-17 11 views
3

私はUIViewControllerを持っています。このコントローラでは、プログラムでUITextViewを作成し、その代理人を自分のコントローラとして設定します。タップしたときにtextViewの編集を開始したくないため、これを行います。UITextView textViewShouldBeginEditingが複数回タップされるとクラッシュする

viewDidLoadメソッド

UITextView* textView = [[UITextView alloc] initWithFrame:CGRectMake(9, 10, 302, 200)]; 
[textView setDelegate:self]; 
[self.view addSubview:textView]; 
[textView release]; 

私が現れてからキーボードを無効にするここに戻っていないためにtextViewShouldBeginEditingメソッドを実装しました。

textViewShouldBeginEditing方法

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView 
{ 
    NSLog(@"Shouldbegin"); 
    return NO; 
} 

私はそれが一回作品のTextViewをタップを表示されますが、私は再びそれをタップすると、それはすべてのログせずに、アプリケーションがクラッシュします問題。私がtextViewを保持し、それを解放すると、私はそれが動作するように動作します奇妙なこと。一方、通常のシングルタップはもう一度動作しません。

編集

シングル、私がx秒待った後、それは文句を言わない動作しているようですので、お互いにも、動作しているようです後すぐに叩きます。

いくつかのテストの後、iOS 5.X>バグのようです。 4.3デバイス/シミュレータで私のアプリケーションを実行するとき、それは必要なように動作します。

Date/Time:  2012-04-17 14:00:49.497 +0200 
OS Version:  iPhone OS 5.1 (9B176) 
Report Version: 104 

Exception Type: EXC_BAD_ACCESS (SIGSEGV) 
Exception Codes: KERN_INVALID_ADDRESS at 0x00000014 
Crashed Thread: 0 

Thread 0 name: Dispatch queue: com.apple.main-thread 
Thread 0 Crashed: 
0 TextInput      0x36bf69e8 TI::Favonius::BeamSearch::choose_hit_test_node(WTF::RefPtr<TI::Favonius::SearchNode> const&, WTF::RefPtr<TI::Favonius::KeyAreaNode> const&, WTF::RefPtr<TI::Favonius::SearchNode> const&, WTF::RefPtr<TI::Favonius::SearchNode> const&) + 12 
1 TextInput      0x36bf6d1e TI::Favonius::BeamSearch::update_for_touch(unsigned int, WTF::PassRefPtr<TI::Favonius::KeyAreaNode>) + 602 
2 TextInput      0x36bfb5c2 TI::Favonius::StrokeBuildManager::update_search_for_touch(unsigned int, int) + 66 
3 TextInput      0x36bfb97c TI::Favonius::StrokeBuildManager::key_down_or_drag_hit_test_for_UI(bool, CGPoint, double, int, int, float, bool, ZT::LayoutDictionaryContext&, bool, int) + 216 
4 TextInput      0x36bddf54 TIInputManagerZephyr::simulate_touches_for_input_string() + 344 
5 TextInput      0x36bed8ba -[TIKeyboardInputManagerZephyr candidates] + 214 
6 UIKit       0x31066616 -[UIKeyboardImpl generateAutocorrectionReplacements:] + 82 
7 UIKit       0x31108a96 __71-[UITextInteractionAssistant scheduleReplacementsForRange:withOptions:]_block_invoke_0 + 370 
8 UIKit       0x3110ec62 -[UITextSelectionView calculateAndShowReplacements:] + 6 
9 Foundation      0x3762192c __NSFireDelayedPerform + 408 
10 CoreFoundation     0x361a1a2c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8 
11 CoreFoundation     0x361a1692 __CFRunLoopDoTimer + 358 
12 CoreFoundation     0x361a0268 __CFRunLoopRun + 1200 
13 CoreFoundation     0x3612349e CFRunLoopRunSpecific + 294 
14 CoreFoundation     0x36123366 CFRunLoopRunInMode + 98 
15 GraphicsServices    0x324e3432 GSEventRunModal + 130 
16 UIKit       0x30e70e76 UIApplicationMain + 1074 
+0

[textView release];あなたのViewDidLoadメソッドから取得し、それを試してください。 –

+0

動作しません:) – Wesley

+0

私の側では、動作しています。しかし、ARC Enableを使用しています。 –

答えて

0

いくつかのテストの後、私はそれがiOS 5.X>バグであることがわかりました。 4.3デバイス/シミュレータで私のアプリケーションを実行するとき、それは必要なように動作します。

ログファイルを編集したメインのポストを見てください。

+0

ARCを使用していない場合は、viewDidLoadメソッドの後に解放されないようにtextViewのプロパティを保持する必要があります(nonatomic)。 – calampunay

0

あなたがそれタップするとUITextViewの編集を開始したくない場合は::のdeallocで

UITextView* textView = ...; 
textView.editable = NO; 
+0

また、クリックしたかどうかを知りたい場合もあります:) – Wesley

+0

UITapGestureRecognizerを試してください –

0
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView 
{ 

    [txtView resignFirstResponder]; 

} 

をとリリースtxtViewのiOS 5.1デバイス上のエラーログには、次のように述べていメソッド

1

私は解決策を見つけました。 Appleのバグを回避することは本当に好きではありませんが、時にはそうする必要があります。 3つのステップ...

1))不可視のビュー

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    myTextView.inputView = customKeyboard; 
} 

2でデフォルトのキーボードを交換する最初の応答者を辞任textViewDidChangeSelectionで編集

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{ 
    return YES; 
} 

3)できるようにYESと応答でありますカーソルを非表示にするには

- (void)textViewDidChangeSelection:(UITextView *)textView{ 
    [textView resignFirstResponder]; 
} 
+0

OKのような仕事のように:-)。私は最終的にそれを修正するために何を覚えていない。 – Wesley

+0

キーボードタイプは数字でなければならないので変更できません。残りのステップは機能しません。 –

関連する問題