Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)viewDidAppear:(BOOL)animated
- {
- [super viewDidAppear:animated];
- [self registerForKeyboardNotifications];
- [self registerForNotifications];
- }
- - (void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [self unregisterForKeyboardNotifications];
- [self unregisterFromNotifications];
- }
- // Called when the UIKeyboardWillShowNotification is sent.
- - (void)keyboardWillBeShown:(NSNotification*)aNotification
- {
- NSDictionary* info = [aNotification userInfo];
- CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
- if (kbSize.height > kbSize.width) SwapDoubleValues(kbSize.height, kbSize.width);
- double kHeight = kbSize.height;
- [_tableView setContentInset:UIEdgeInsetsMake(0, 0, kHeight, 0)];
- UIEdgeInsets scrollInsets = _tableView.scrollIndicatorInsets;
- scrollInsets.bottom = kHeight;
- [_tableView setScrollIndicatorInsets:scrollInsets];
- _tableView.scrollEnabled = NO;
- }
- // Called when the UIKeyboardWillHideNotification is sent
- - (void)keyboardWillBeHidden:(NSNotification*)aNotification
- {
- NSDictionary* info = [aNotification userInfo];
- CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
- if (kbSize.height > kbSize.width) SwapDoubleValues(kbSize.height, kbSize.width);
- double duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
- [UIView animateWithDuration:duration animations:^{
- [_tableView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
- UIEdgeInsets scrollInsets = _tableView.scrollIndicatorInsets;
- scrollInsets.bottom = 0;
- [_tableView setScrollIndicatorInsets:scrollInsets];
- } completion:nil];
- _tableView.scrollEnabled = YES;
- [self.firstResponder resignFirstResponder];
- self.firstResponder = nil;
- }
- - (void)textViewDidBeginEditing:(UITextView *)textView
- {
- self.firstResponder = textView;
- CGRect rect = CGRectZero;
- if (textView.tag == TAG_FLIGHT_TEXT_VIEW)
- {
- rect = [_tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
- rect.origin.y += textView.superview.frame.origin.y;
- rect.size.height = textView.frame.size.height + 10;
- }
- else if (textView.tag == TAG_COMMENT_TEXT_VIEW)
- {
- rect = [_tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:[_tableView numberOfRowsInSection:1]-1 inSection:1]];
- }
- double extra = 100;
- if (self.view.bounds.size.height > 500) extra = 180;
- double offset = CGRectGetMinY(rect) - extra;
- [_tableView setContentOffset:CGPointMake(0, offset) animated:YES];
- }
- - (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
- {
- UIImage *bckGrnd = [[UIImage imageNamed:@"bg_navigationbar"] resizableImageWithCapInsets:UIEdgeInsetsMake(22, 160, 21, 159)];
- [[UINavigationBar appearance] setBackgroundImage:bckGrnd forBarMetrics:UIBarMetricsDefault];
- [controller dismissViewControllerAnimated:YES completion:^{
- if (result == MFMailComposeResultSent)
- {
- [SVProgressHUD showSuccessWithStatus:@"Sent"];
- }
- else if (result == MFMailComposeResultFailed || result == MFMailComposeResultCancelled)
- {
- [SVProgressHUD showErrorWithStatus:nil];
- }
- else if (result == MFMailComposeResultSaved)
- {
- [SVProgressHUD showSuccessWithStatus:@"Saved"];
- }
- [[AppDelegate shared] configureAppearance];
- }];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement