3

我有一个 UITextField 我在模式对话框中呈现。在触摸 UITextField 时,会显示 ABPeoplePicker(联系人选择器)(也是模态的)。如果我随后关闭 ABPeoplePicker 和最初呈现的模式对话框,然后将应用程序置于后台,我会在应用程序恢复时遇到 EXC_BAD_ACCESS 崩溃。

使用僵尸:

#   Address Category    Event Type  RefCt   Timestamp   Size    Responsible Library Responsible Caller
0   0xda96640   UITextField Malloc  1   00:05.995.892   336 UIKit   UINibDecoderDecodeObjectForValue
1   0xda96640   UITextField Retain  2   00:05.996.496   0   UIKit   -[UIRuntimeConnection initWithCoder:]
2   0xda96640   UITextField Retain  3   00:05.996.504   0   UIKit   -[UIRuntimeConnection initWithCoder:]
3   0xda96640   UITextField Retain  4   00:05.998.852   0   UIKit   UINibDecoderDecodeObjectForValue
4   0xda96640   UITextField Retain  5   00:05.998.870   0   UIKit   -[UIView(Internal) _addSubview:positioned:relativeTo:]
5   0xda96640   UITextField Retain  6   00:06.010.519   0   UIKit   -[UIRuntimeConnection initWithCoder:]
6   0xda96640   UITextField Retain  7   00:06.010.991   0   UIKit   UINibDecoderDecodeObjectForValue
7   0xda96640   UITextField Release 6   00:06.011.441   0   UIKit   -[UINibDecoder finishDecoding]
8   0xda96640   UITextField Release 5   00:06.011.489   0   UIKit   -[UINibDecoder finishDecoding]
9   0xda96640   UITextField Release 4   00:06.011.532   0   UIKit   -[UINibDecoder finishDecoding]
10  0xda96640   UITextField Release 3   00:06.011.581   0   UIKit   -[UIRuntimeConnection dealloc]
11  0xda96640   UITextField Release 2   00:06.011.659   0   UIKit   -[UIRuntimeConnection dealloc]
12  0xda96640   UITextField Release 1   00:06.011.718   0   UIKit   -[UIRuntimeConnection dealloc]
13  0xda96640   UITextField Retain  2   00:06.060.566   0   UIKit   -[UIView _tryRetain]
14  0xda96640   UITextField Autorelease     00:06.060.567   0   MyApp   -[MDDueViewController customerField]
15  0xda96640   UITextField Retain  3   00:06.060.567   0   MyApp   -[MDDueViewController refreshView]
16  0xda96640   UITextField Release 2   00:06.060.569   0   MyApp   -[MDDueViewController refreshView]
17  0xda96640   UITextField Retain  3   00:06.060.574   0   UIKit   -[UIView _tryRetain]
18  0xda96640   UITextField Autorelease     00:06.060.575   0   MyApp   -[MDDueViewController customerField]
19  0xda96640   UITextField Retain  4   00:06.060.575   0   MyApp   -[MDDueViewController refreshView]
20  0xda96640   UITextField Release 3   00:06.060.669   0   MyApp   -[MDDueViewController refreshView]
21  0xda96640   UITextField Retain  4   00:06.060.961   0   UIKit   -[UIView _tryRetain]
22  0xda96640   UITextField Autorelease     00:06.060.962   0   MyApp   -[MDDueViewController customerField]
23  0xda96640   UITextField Retain  5   00:06.060.962   0   MyApp   -[MDDueViewController refreshView]
24  0xda96640   UITextField Release 4   00:06.060.963   0   MyApp   -[MDDueViewController refreshView]
25  0xda96640   UITextField Release 3   00:06.066.904   0   UIKit   _UIApplicationHandleEvent
26  0xda96640   UITextField Release 2   00:06.066.954   0   UIKit   _UIApplicationHandleEvent
27  0xda96640   UITextField Release 1   00:06.066.955   0   UIKit   _UIApplicationHandleEvent
28  0xda96640   UITextField Retain  2   00:06.072.625   0   QuartzCore  -[CALayer layoutSublayers]
29  0xda96640   UITextField Release 1   00:06.072.809   0   QuartzCore  -[CALayer layoutSublayers]
30  0xda96640   UITextField Retain  2   00:06.074.635   0   QuartzCore  -[CALayer drawInContext:]
31  0xda96640   UITextField Release 1   00:06.074.645   0   QuartzCore  -[CALayer drawInContext:]
32  0xda96640   UITextField Retain  2   00:07.399.074   0   UIKit   -[UIView(Hierarchy) subviews]
33  0xda96640   UITextField Retain  3   00:07.960.376   0   UIKit   -[UITouch(UITouchInternal) setView:]
34  0xda96640   UITextField Retain  4   00:07.960.377   0   UIKit   -[UITouch(UITouchInternal) setGestureView:]
35  0xda96640   UITextField Retain  5   00:07.960.398   0   UIKit   -[UITouch view]
36  0xda96640   UITextField Autorelease     00:07.960.399   0   UIKit   -[UITouch view]
37  0xda96640   UITextField Retain  6   00:07.960.435   0   UIKit   -[UITouch view]
38  0xda96640   UITextField Autorelease     00:07.960.436   0   UIKit   -[UITouch view]
39  0xda96640   UITextField Retain  7   00:07.960.445   0   UIKit   -[UITouch view]
40  0xda96640   UITextField Autorelease     00:07.960.445   0   UIKit   -[UITouch view]
41  0xda96640   UITextField Retain  8   00:07.960.451   0   UIKit   -[UITouch view]
42  0xda96640   UITextField Autorelease     00:07.960.451   0   UIKit   -[UITouch view]
43  0xda96640   UITextField Retain  9   00:07.960.460   0   UIKit   -[UITouch view]
44  0xda96640   UITextField Autorelease     00:07.960.461   0   UIKit   -[UITouch view]
45  0xda96640   UITextField Retain  10  00:07.960.466   0   UIKit   -[UITouch view]
46  0xda96640   UITextField Autorelease     00:07.960.467   0   UIKit   -[UITouch view]
47  0xda96640   UITextField Retain  11  00:07.960.473   0   UIKit   -[UITouch view]
48  0xda96640   UITextField Autorelease     00:07.960.473   0   UIKit   -[UITouch view]
49  0xda96640   UITextField Retain  12  00:07.960.483   0   UIKit   -[UITouch view]
50  0xda96640   UITextField Autorelease     00:07.960.483   0   UIKit   -[UITouch view]
51  0xda96640   UITextField Retain  13  00:07.960.541   0   UIKit   -[UITouch view]
52  0xda96640   UITextField Autorelease     00:07.960.541   0   UIKit   -[UITouch view]
53  0xda96640   UITextField Retain  14  00:07.960.846   0   UIKit   -[UITouch view]
54  0xda96640   UITextField Autorelease     00:07.960.847   0   UIKit   -[UITouch view]
55  0xda96640   UITextField Retain  15  00:07.961.119   0   UIKit   -[UITouchesEvent _cloneEvent]
56  0xda96640   UITextField Retain  16  00:07.961.181   0   UIKit   -[UITouch _loadStateFromTouch:]
57  0xda96640   UITextField Retain  17  00:07.961.210   0   UIKit   -[UITouch view]
58  0xda96640   UITextField Autorelease     00:07.961.210   0   UIKit   -[UITouch view]
59  0xda96640   UITextField Retain  18  00:07.961.212   0   UIKit   -[UITouchesEvent _viewsForWindow:]
60  0xda96640   UITextField Retain  19  00:07.961.218   0   UIKit   -[UITouch view]
61  0xda96640   UITextField Autorelease     00:07.961.218   0   UIKit   -[UITouch view]
62  0xda96640   UITextField Release 18  00:07.961.221   0   UIKit   _UIApplicationHandleEvent
63  0xda96640   UITextField Release 17  00:07.961.225   0   UIKit   _UIApplicationHandleEvent
64  0xda96640   UITextField Release 16  00:07.961.226   0   UIKit   _UIApplicationHandleEvent
65  0xda96640   UITextField Release 15  00:07.961.244   0   UIKit   _UIApplicationHandleEvent
66  0xda96640   UITextField Release 14  00:07.961.260   0   UIKit   _UIApplicationHandleEvent
67  0xda96640   UITextField Release 13  00:07.961.271   0   UIKit   _UIApplicationHandleEvent
68  0xda96640   UITextField Release 12  00:07.961.278   0   UIKit   _UIApplicationHandleEvent
69  0xda96640   UITextField Release 11  00:07.961.278   0   UIKit   _UIApplicationHandleEvent
70  0xda96640   UITextField Release 10  00:07.961.279   0   UIKit   _UIApplicationHandleEvent
71  0xda96640   UITextField Release 9   00:07.961.279   0   UIKit   _UIApplicationHandleEvent
72  0xda96640   UITextField Release 8   00:07.961.279   0   UIKit   _UIApplicationHandleEvent
73  0xda96640   UITextField Release 7   00:07.961.280   0   UIKit   _UIApplicationHandleEvent
74  0xda96640   UITextField Release 6   00:07.961.280   0   UIKit   _UIApplicationHandleEvent
75  0xda96640   UITextField Release 5   00:07.961.286   0   UIKit   _UIApplicationHandleEvent
76  0xda96640   UITextField Retain  6   00:07.961.311   0   QuartzCore  -[CALayer layoutSublayers]
77  0xda96640   UITextField Release 5   00:07.961.403   0   QuartzCore  -[CALayer layoutSublayers]
78  0xda96640   UITextField Retain  6   00:08.038.720   0   UIKit   -[UITouch view]
79  0xda96640   UITextField Autorelease     00:08.038.721   0   UIKit   -[UITouch view]
80  0xda96640   UITextField Retain  7   00:08.039.129   0   UIKit   -[UITouch view]
81  0xda96640   UITextField Autorelease     00:08.039.130   0   UIKit   -[UITouch view]
82  0xda96640   UITextField Retain  8   00:08.039.422   0   UIKit   -[UITouch view]
83  0xda96640   UITextField Autorelease     00:08.039.422   0   UIKit   -[UITouch view]
84  0xda96640   UITextField Retain  9   00:08.039.425   0   UIKit   -[UITouch view]
85  0xda96640   UITextField Autorelease     00:08.039.426   0   UIKit   -[UITouch view]
86  0xda96640   UITextField Retain  10  00:08.039.428   0   UIKit   -[UIGestureRecognizer _shouldBegin]
87  0xda96640   UITextField Release 9   00:08.039.435   0   UIKit   -[UIGestureRecognizer _shouldBegin]
88  0xda96640   UITextField Retain  10  00:08.039.644   0   UIKit   -[UITouchesEvent _cloneEvent]
89  0xda96640   UITextField Retain  11  00:08.039.744   0   UIKit   -[UITouch _loadStateFromTouch:]
90  0xda96640   UITextField Retain  12  00:08.039.782   0   UIKit   -[UIResponder becomeFirstResponder]
91  0xda96640   UITextField Retain  13  00:08.039.831   0   UIKit   -[UIWindow _setFirstResponder:]
92  0xda96640   UITextField Retain  14  00:08.041.734   0   UIKit   -[UIFieldEditor becomeFieldEditorForView:]
93  0xda96640   UITextField Retain  15  00:08.042.968   0   MyApp   -[MDDueViewController customerBeginEditing:]
94  0xda96640   UITextField Retain  16  00:08.083.655   0   UIKit   -[UIViewController presentViewController:withTransition:completion:]
95  0xda96640   UITextField Retain  17  00:08.095.495   0   UIKit   -[UITextField _resignFirstResponder]
96  0xda96640   UITextField Autorelease     00:08.095.496   0   UIKit   -[UITextField _resignFirstResponder]
97  0xda96640   UITextField Retain  18  00:08.095.796   0   UIKit   -[UIView _tryRetain]
98  0xda96640   UITextField Autorelease     00:08.095.797   0   MyApp   -[MDDueViewController customerField]
99  0xda96640   UITextField Retain  19  00:08.095.798   0   MyApp   -[MDDueViewController customerFieldDidEndEditing:]
100 0xda96640   UITextField Retain  20  00:08.095.818   0   UIKit   -[UIView _tryRetain]
101 0xda96640   UITextField Autorelease     00:08.095.819   0   MyApp   -[MDDueViewController customerField]
102 0xda96640   UITextField Retain  21  00:08.095.820   0   MyApp   -[MDDueViewController customerFieldDidEndEditing:]
103 0xda96640   UITextField Release 20  00:08.095.838   0   MyApp   -[MDDueViewController customerFieldDidEndEditing:]
104 0xda96640   UITextField Release 19  00:08.095.839   0   MyApp   -[MDDueViewController customerFieldDidEndEditing:]
105 0xda96640   UITextField Release 18  00:08.095.869   0   UIKit   -[UIFieldEditor becomeFieldEditorForView:]
106 0xda96640   UITextField Retain  19  00:08.096.237   0   Foundation  +[NSConcreteNotification newTempNotificationWithName:object:userInfo:]
107 0xda96640   UITextField Release 18  00:08.096.243   0   Foundation  -[NSConcreteNotification dealloc]
108 0xda96640   UITextField Release 17  00:08.096.248   0   MyApp   -[MDDueViewController customerBeginEditing:]
109 0xda96640   UITextField Retain  18  00:08.097.915   0   Foundation  +[NSConcreteNotification newTempNotificationWithName:object:userInfo:]
110 0xda96640   UITextField Release 17  00:08.097.919   0   Foundation  -[NSConcreteNotification dealloc]
111 0xda96640   UITextField Release 16  00:08.097.929   0   UIKit   -[UIResponder becomeFirstResponder]
112 0xda96640   UITextField Retain  17  00:08.097.939   0   UIKit   -[UITouch view]
113 0xda96640   UITextField Autorelease     00:08.097.939   0   UIKit   -[UITouch view]
114 0xda96640   UITextField Retain  18  00:08.097.979   0   UIKit   -[UITouch view]
115 0xda96640   UITextField Autorelease     00:08.097.980   0   UIKit   -[UITouch view]
116 0xda96640   UITextField Retain  19  00:08.097.981   0   UIKit   -[UITouch view]
117 0xda96640   UITextField Autorelease     00:08.097.981   0   UIKit   -[UITouch view]
118 0xda96640   UITextField Retain  20  00:08.097.984   0   UIKit   -[UITouch view]
119 0xda96640   UITextField Autorelease     00:08.097.985   0   UIKit   -[UITouch view]
120 0xda96640   UITextField Retain  21  00:08.097.989   0   UIKit   -[UIApplication _cancelTouches:withEvent:includingGestures:notificationBlock:]
121 0xda96640   UITextField Retain  22  00:08.098.003   0   UIKit   __98-[UIApplication _cancelViewProcessingOfTouches:withEvent:sendingTouchesCancelledToViewsOfTouches:]_block_invoke_0
122 0xda96640   UITextField Retain  23  00:08.098.032   0   UIKit   -[UIApplication _cancelTouches:withEvent:includingGestures:notificationBlock:]
123 0xda96640   UITextField Retain  24  00:08.098.049   0   UIKit   -[UITouch view]
124 0xda96640   UITextField Autorelease     00:08.098.049   0   UIKit   -[UITouch view]
125 0xda96640   UITextField Release 23  00:08.098.050   0   UIKit   -[UITouch(UITouchInternal) setView:]
126 0xda96640   UITextField Release 22  00:08.098.051   0   UIKit   -[UITouch(UITouchInternal) setGestureView:]
127 0xda96640   UITextField Release 21  00:08.098.070   0   UIKit   -[UIApplication _cancelTouches:withEvent:includingGestures:notificationBlock:]
128 0xda96640   UITextField Release 20  00:08.098.415   0   UIKit   _UIApplicationHandleEvent
129 0xda96640   UITextField Release 19  00:08.098.422   0   UIKit   _UIApplicationHandleEvent
130 0xda96640   UITextField Release 18  00:08.098.427   0   UIKit   _UIApplicationHandleEvent
131 0xda96640   UITextField Release 17  00:08.098.428   0   UIKit   _UIApplicationHandleEvent
132 0xda96640   UITextField Release 16  00:08.098.429   0   UIKit   _UIApplicationHandleEvent
133 0xda96640   UITextField Release 15  00:08.098.429   0   UIKit   _UIApplicationHandleEvent
134 0xda96640   UITextField Release 14  00:08.098.445   0   UIKit   _UIApplicationHandleEvent
135 0xda96640   UITextField Release 13  00:08.098.548   0   UIKit   _UIApplicationHandleEvent
136 0xda96640   UITextField Release 12  00:08.098.552   0   UIKit   _UIApplicationHandleEvent
137 0xda96640   UITextField Release 11  00:08.098.592   0   UIKit   _UIApplicationHandleEvent
138 0xda96640   UITextField Release 10  00:08.099.264   0   UIKit   _UIApplicationHandleEvent
139 0xda96640   UITextField Release 9   00:08.099.275   0   UIKit   -[UITouch dealloc]
140 0xda96640   UITextField Release 8   00:08.099.356   0   UIKit   _UIApplicationHandleEvent
141 0xda96640   UITextField Release 7   00:08.099.372   0   UIKit   _UIApplicationHandleEvent
142 0xda96640   UITextField Release 6   00:08.099.373   0   UIKit   _UIApplicationHandleEvent
143 0xda96640   UITextField Release 5   00:08.099.383   0   UIKit   _UIApplicationHandleEvent
144 0xda96640   UITextField Release 4   00:08.099.385   0   UIKit   -[UITouch dealloc]
145 0xda96640   UITextField Release 3   00:08.099.656   0   UIKit   _UIApplicationHandleEvent
146 0xda96640   UITextField Retain  4   00:08.102.385   0   QuartzCore  -[CALayer layoutSublayers]
147 0xda96640   UITextField Release 3   00:08.102.455   0   QuartzCore  -[CALayer layoutSublayers]
148 0xda96640   UITextField Retain  4   00:10.762.824   0   UIKit   -[UIView _tryRetain]
149 0xda96640   UITextField Autorelease     00:10.762.825   0   MyApp   -[MDDueViewController customerField]
150 0xda96640   UITextField Retain  5   00:10.762.825   0   MyApp   -[MDDueViewController refreshView]
151 0xda96640   UITextField Release 4   00:10.762.828   0   MyApp   -[MDDueViewController refreshView]
152 0xda96640   UITextField Retain  5   00:10.762.833   0   UIKit   -[UIView _tryRetain]
153 0xda96640   UITextField Autorelease     00:10.762.833   0   MyApp   -[MDDueViewController customerField]
154 0xda96640   UITextField Retain  6   00:10.762.834   0   MyApp   -[MDDueViewController refreshView]
155 0xda96640   UITextField Release 5   00:10.762.888   0   MyApp   -[MDDueViewController refreshView]
156 0xda96640   UITextField Retain  6   00:10.763.054   0   UIKit   -[UIView _tryRetain]
157 0xda96640   UITextField Autorelease     00:10.763.054   0   MyApp   -[MDDueViewController customerField]
158 0xda96640   UITextField Retain  7   00:10.763.055   0   MyApp   -[MDDueViewController refreshView]
159 0xda96640   UITextField Release 6   00:10.763.056   0   MyApp   -[MDDueViewController refreshView]
160 0xda96640   UITextField Retain  7   00:10.768.666   0   UIKit   -[UIResponder becomeFirstResponder]
161 0xda96640   UITextField Retain  8   00:10.768.678   0   UIKit   -[UIWindow _setFirstResponder:]
162 0xda96640   UITextField Retain  9   00:10.768.753   0   UIKit   -[UIFieldEditor becomeFieldEditorForView:]
163 0xda96640   UITextField Retain  10  00:10.769.010   0   MyApp   -[MDDueViewController customerBeginEditing:]
164 0xda96640   UITextField Retain  11  00:10.796.341   0   UIKit   -[UITextField _resignFirstResponder]
165 0xda96640   UITextField Autorelease     00:10.796.342   0   UIKit   -[UITextField _resignFirstResponder]
166 0xda96640   UITextField Retain  12  00:10.796.506   0   UIKit   -[UIView _tryRetain]
167 0xda96640   UITextField Autorelease     00:10.796.507   0   MyApp   -[MDDueViewController customerField]
168 0xda96640   UITextField Retain  13  00:10.796.508   0   MyApp   -[MDDueViewController customerFieldDidEndEditing:]
169 0xda96640   UITextField Retain  14  00:10.796.522   0   UIKit   -[UIView _tryRetain]
170 0xda96640   UITextField Autorelease     00:10.796.523   0   MyApp   -[MDDueViewController customerField]
171 0xda96640   UITextField Retain  15  00:10.796.524   0   MyApp   -[MDDueViewController customerFieldDidEndEditing:]
172 0xda96640   UITextField Release 14  00:10.796.536   0   MyApp   -[MDDueViewController customerFieldDidEndEditing:]
173 0xda96640   UITextField Release 13  00:10.796.537   0   MyApp   -[MDDueViewController customerFieldDidEndEditing:]
174 0xda96640   UITextField Release 12  00:10.796.562   0   UIKit   -[UIFieldEditor becomeFieldEditorForView:]
175 0xda96640   UITextField Retain  13  00:10.796.980   0   Foundation  +[NSConcreteNotification newTempNotificationWithName:object:userInfo:]
176 0xda96640   UITextField Release 12  00:10.796.983   0   Foundation  -[NSConcreteNotification dealloc]
177 0xda96640   UITextField Release 11  00:10.797.049   0   MyApp   -[MDDueViewController customerBeginEditing:]
178 0xda96640   UITextField Retain  12  00:10.797.754   0   Foundation  +[NSConcreteNotification newTempNotificationWithName:object:userInfo:]
179 0xda96640   UITextField Release 11  00:10.797.757   0   Foundation  -[NSConcreteNotification dealloc]
180 0xda96640   UITextField Release 10  00:10.797.763   0   UIKit   -[UIResponder becomeFirstResponder]
181 0xda96640   UITextField Release 9   00:10.797.944   0   UIKit   -[UIViewController _dismissViewControllerWithTransition:from:completion:]
182 0xda96640   UITextField Release 8   00:10.798.036   0   UIKit   _UIApplicationHandleEvent
183 0xda96640   UITextField Release 7   00:10.798.040   0   UIKit   _UIApplicationHandleEvent
184 0xda96640   UITextField Release 6   00:10.798.051   0   UIKit   _UIApplicationHandleEvent
185 0xda96640   UITextField Release 5   00:10.802.137   0   UIKit   _UIApplicationHandleEvent
186 0xda96640   UITextField Release 4   00:10.802.827   0   UIKit   _UIApplicationHandleEvent
187 0xda96640   UITextField Release 3   00:10.802.867   0   UIKit   _UIApplicationHandleEvent
188 0xda96640   UITextField Release 2   00:10.802.868   0   UIKit   _UIApplicationHandleEvent
189 0xda96640   UITextField Retain  3   00:10.803.307   0   QuartzCore  -[CALayer layoutSublayers]
190 0xda96640   UITextField Release 2   00:10.803.419   0   QuartzCore  -[CALayer layoutSublayers]
191 0xda96640   UITextField Retain  3   00:14.465.011   0   QuartzCore  -[CALayer layoutSublayers]
192 0xda96640   UITextField Release 2   00:14.465.118   0   QuartzCore  -[CALayer layoutSublayers]
193 0xda96640   UITextField Release 1   00:17.082.546   0   UIKit   -[UIView(Internal) _invalidateSubviewCache]
194 0xda96640   UITextField Release 0   00:17.082.555   0   UIKit   -[UIView(Hierarchy) removeFromSuperview]
195 0xda96640   UITextField Zombie  -1  00:19.533.987   0   Foundation  __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0

我在这里没有做任何太花哨的事情。我只是将我的几个 ViewController 方法绑定到情节提要中的 UITextField 的“Editing Did Begin”和“Editing Did End”事件,以便呈现和关闭 ABPeoplePicker:

- (IBAction)customerBeginEditing:(id)sender {
    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    picker.peoplePickerDelegate = self;
    // Display only a person's phone, email, and birthdate
    NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty], 
                               [NSNumber numberWithInt:kABPersonEmailProperty], nil];


    picker.displayedProperties = displayedItems;
    // Show the picker 
    [self presentModalViewController:picker animated:YES]; 
    [sender resignFirstResponder]; //dismiss the keyboard from under the contact picker

}

选择联系人后,会发生以下情况 (ABPeoplePickerNavigationControllerDelegate):

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {    
    [self setCustomerFromSelectedPerson:person];
    [self dismissModalViewControllerAnimated:YES];
    return NO;

}

最后:

- (void)customerFieldDidEndEditing:(UITextField *)textField {
    if (self.customerField.text != nil && self.customerField.text.length > 0) {
        self.saveButton.enabled = YES;
    } else {
        self.saveButton.enabled = NO;
    }
}

有趣的是,崩溃只发生在 iOS 6 中。iOS 5 运行良好。

iOS 内部是否有一些与通知相关的东西试图以某种方式向我的 UITextField 发送消息?我缺少一些潜在的清理任务?我在其他地方使用相同的技术没有问题,这真的让我很困惑。我什至尝试将原始文本字段移动到“推送”样式演示文稿(而不是模态),以排除由于嵌套的模态呈现对话框引起的任何问题。

请注意,我使用的是 ARC,并且 UITextField 在我的 ViewController 中被声明为弱引用。

任何见解都非常感谢!谢谢!

更新

好的,我发现了问题,但我不明白为什么会这样。我已将问题归结为在 customerBeginEditing 中对 [sender resignFirstResponder] 的调用。出于某种原因,此调用导致在应用程序恢复时调用 [NSNotificationCenter addObserver:selector:name:object:](但仅当不再显示具有 UITextField 的页面时)。我可以通过修改我的代码来解决我的问题,以便根本不必调用 resignFirstResponder 但我仍然不明白 iOS5 和 iOS6 之间发生了什么变化导致了这个问题。有人有想法么?

4

0 回答 0