Been getting this odd error.
heres the d开发者_运维问答eal - in the below method i have an alert view come up, take a U/N and PW, then atempt to start another method.
The method
-postTweet
does not get activated
I just get this error in console
wait_fences: failed to receive reply: 10004003
Which is really odd - as ive never seen it before
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (alertView == completeAlert ) {
if (buttonIndex ==1) {
passPromtAlert = [[UIAlertView alloc] initWithTitle:@"Enter Name" message:@"Please enter your Username and password - they will be saved\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Tweet", nil];
[passPromtAlert addTextFieldWithValue:@"" label:@"Enter username"];
[passPromtAlert addTextFieldWithValue:@"" label:@"Enter password"];
textField = [passPromtAlert textFieldAtIndex:0];
textField2 = [passPromtAlert textFieldAtIndex:1];
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.keyboardType = UIKeyboardTypeAlphabet;
textField.keyboardAppearance = UIKeyboardAppearanceAlert;
textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
textField.autocorrectionType = UITextAutocapitalizationTypeNone;
textField.textAlignment = UITextAlignmentCenter;
textField2.secureTextEntry = YES;
textField2.clearButtonMode = UITextFieldViewModeWhileEditing;
textField2.keyboardType = UIKeyboardTypeAlphabet;
textField2.keyboardAppearance = UIKeyboardAppearanceAlert;
textField2.autocapitalizationType = UITextAutocapitalizationTypeWords;
textField2.autocorrectionType = UITextAutocapitalizationTypeNone;
textField2.textAlignment = UITextAlignmentCenter;
[passPromtAlert show];
}
}
if (alertView == passPromtAlert ) {
if (buttonIndex == 1) {
NSLog(@"here");
[self postTweet];
}
}
}
Any help would be appreciated
Thanks
Sam
ADDED:
If you need to see more code, then let me know
Here I was also facing the same issue in my project and I managed to solve the issue now. You need to call the method using NSTimer.
So, Here you are calling one alert inside another alert means when one alert dismiss then the new alert you are calling there. There is no problem in that. You can do it easily. Instead of defining alertview inside the method "- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (alertView == completeAlert )", You can create one method e.g. "Show_AlertMessage" and call it using timer like this.
[NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(Show_AlertMessage) userInfo:nil repeats:NO];
Let me know if you can get rid of this issue. We will solve this issue as I did for my side.
I believe the problem is caused by you creating another alert view before you dismiss the first one. Since only one alert view is supposed to be present at anyone one time the second alert view is stepping on the first one.
You need to dismiss the first view before creating and showing the second.
Solution is here! I had same error, now i got the solution, this may help you. Use this delegate of AlertView
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
Your UITextField*
isn't resigning its firstresponder status before the alert is dismissed.
This messes up the responder chain. Add [textField resignFirstResponder]
or [textField2 resignFirstResponder]
as applicable in the UIAlertViewDelegate implementation (alertView:clickedButtonAtIndex:
)
Also, schedule your second UIAlertView to show after the first is dismissed (you can do this using (performSelector:withObject:afterDelay:
)
精彩评论