以下是相关代码的结构:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if(!isResponding) {
...
else {
...
[respondButton setUserInteractionEnabled:NO];
[respondButton setEnabled:NO];
[_manager POST:queryStringss parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:imageData name:@"file" fileName:usernameEncoded mimeType:@"image/jpeg"];}
success:^(AFHTTPRequestOperation *operation, id responseObject) {
...
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@ ***** %@", operation.responseString, error);
...
}
}
];
[respondButton setUserInteractionEnabled:YES];
[respondButton setEnabled:YES];
...
}
我看过,我不会在不知情的情况下重新启用该按钮,它永远不会禁用。周围的代码运行。请帮助,谢谢。
答案 0 :(得分:0)
您应该将代码移到块中,它应该可以正常工作。
[respondButton setUserInteractionEnabled:NO];
[respondButton setEnabled:NO];
[_manager POST:queryStringss parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:imageData name:@"file" fileName:usernameEncoded mimeType:@"image/jpeg"];}
success:^(AFHTTPRequestOperation *operation, id responseObject) {
...
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@ ***** %@", operation.responseString, error);
...
}
[respondButton setUserInteractionEnabled:YES];
[respondButton setEnabled:YES];
}
];
答案 1 :(得分:0)
在您的网络请求成功或失败后启用了打开的用户交互
[respondButton setUserInteractionEnabled:NO];
[respondButton setEnabled:NO];
[_manager POST:queryStringss parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:imageData name:@"file" fileName:usernameEncoded mimeType:@"image/jpeg"];}
success:^(AFHTTPRequestOperation *operation, id responseObject) {
...
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@ ***** %@", operation.responseString, error);
[respondButton setUserInteractionEnabled:YES];
[respondButton setEnabled:YES];
}
}
];