mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-01 07:57:01 +00:00
Fix rotation issues with Feedback list view
This commit is contained in:
parent
b486b8142c
commit
4ac8c6e7a8
@ -93,6 +93,47 @@
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Keyboard
|
||||
|
||||
- (void)keyboardWasShown:(NSNotification*)aNotification {
|
||||
NSDictionary* info = [aNotification userInfo];
|
||||
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
|
||||
|
||||
CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
|
||||
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
|
||||
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
|
||||
frame.size.height -= kbSize.height;
|
||||
else
|
||||
frame.size.height -= kbSize.width;
|
||||
} else {
|
||||
CGSize windowSize = [[UIScreen mainScreen] bounds].size;
|
||||
CGFloat windowHeight = windowSize.height - 20;
|
||||
CGFloat navBarHeight = self.navigationController.navigationBar.frame.size.height;
|
||||
|
||||
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
|
||||
CGFloat modalGap = (windowHeight - self.view.bounds.size.height) / 2;
|
||||
frame.size.height = windowHeight - navBarHeight - modalGap - kbSize.height;
|
||||
} else {
|
||||
windowHeight = windowSize.width - 20;
|
||||
CGFloat modalGap = 0.0f;
|
||||
if (windowHeight - kbSize.width < self.view.bounds.size.height) {
|
||||
modalGap = 30;
|
||||
} else {
|
||||
modalGap = (windowHeight - self.view.bounds.size.height) / 2;
|
||||
}
|
||||
frame.size.height = windowSize.width - navBarHeight - modalGap - kbSize.width;
|
||||
}
|
||||
NSLog(@"%@", NSStringFromCGRect(frame));
|
||||
}
|
||||
[self.textView setFrame:frame];
|
||||
}
|
||||
|
||||
- (void)keyboardWillBeHidden:(NSNotification*)aNotification {
|
||||
CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
|
||||
[self.textView setFrame:frame];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - View lifecycle
|
||||
|
||||
- (void)viewDidLoad {
|
||||
@ -111,14 +152,7 @@
|
||||
action:@selector(sendAction:)] autorelease];
|
||||
|
||||
// message input textfield
|
||||
CGRect frame = CGRectZero;
|
||||
|
||||
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
|
||||
frame = CGRectMake(0, 0, self.view.bounds.size.width, 200);
|
||||
} else {
|
||||
frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
|
||||
}
|
||||
self.textView = [[[UITextView alloc] initWithFrame:frame] autorelease];
|
||||
self.textView = [[[UITextView alloc] initWithFrame:self.view.frame] autorelease];
|
||||
self.textView.font = [UIFont systemFontOfSize:17];
|
||||
self.textView.delegate = self;
|
||||
self.textView.backgroundColor = [UIColor whiteColor];
|
||||
@ -128,12 +162,22 @@
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWasShown:)
|
||||
name:UIKeyboardDidShowNotification object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillBeHidden:)
|
||||
name:UIKeyboardWillHideNotification object:nil];
|
||||
|
||||
self.manager.currentFeedbackComposeViewController = self;
|
||||
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:(self.navigationController.navigationBar.barStyle == UIBarStyleDefault) ? UIStatusBarStyleDefault : UIStatusBarStyleBlackOpaque];
|
||||
|
||||
[self.textView setFrame:self.view.frame];
|
||||
|
||||
if (_text) {
|
||||
self.textView.text = _text;
|
||||
self.navigationItem.rightBarButtonItem.enabled = YES;
|
||||
@ -157,6 +201,9 @@
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
|
||||
|
||||
self.manager.currentFeedbackComposeViewController = nil;
|
||||
|
||||
[super viewWillDisappear:animated];
|
||||
@ -167,6 +214,13 @@
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UIViewController Rotation
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Private methods
|
||||
|
||||
- (void)dismiss {
|
||||
|
@ -134,6 +134,7 @@
|
||||
|
||||
- (void)layoutSubviews {
|
||||
UIView *accessoryViewBackground = [[[UIView alloc] initWithFrame:CGRectMake(0, 2, self.frame.size.width * 2, self.frame.size.height - 2)] autorelease];
|
||||
accessoryViewBackground.autoresizingMask = UIViewAutoresizingFlexibleHeight;
|
||||
|
||||
// colors
|
||||
if (_backgroundStyle == BITFeedbackListViewCellBackgroundStyleNormal) {
|
||||
|
@ -192,6 +192,7 @@
|
||||
userController.delegate = self;
|
||||
|
||||
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:userController] autorelease];
|
||||
navController.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||
|
||||
[self.navigationController presentModalViewController:navController animated:YES];
|
||||
}
|
||||
@ -249,6 +250,18 @@
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UIViewController Rotation
|
||||
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
||||
[self.tableView beginUpdates];
|
||||
[self.tableView endUpdates];
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
@ -331,6 +344,7 @@
|
||||
[button setTitleColor:BUTTON_TEXTCOLOR forState:UIControlStateNormal];
|
||||
[button setTitleShadowColor:BUTTON_TEXTCOLOR_SHADOW forState:UIControlStateNormal];
|
||||
if (indexPath.section == 0) {
|
||||
topGap += 22;
|
||||
if ([self.manager numberOfMessages] == 0) {
|
||||
[button setTitle:BITHockeyLocalizedString(@"HockeyFeedbackListButonWriteFeedback") forState:UIControlStateNormal];
|
||||
} else {
|
||||
@ -356,6 +370,7 @@
|
||||
[button setTitle:title forState:UIControlStateNormal];
|
||||
[button addTarget:self action:@selector(setUserDataAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
} else {
|
||||
topGap -= 6.0f;
|
||||
[button.layer setBackgroundColor:BUTTON_DELETE_BACKGROUNDCOLOR.CGColor];
|
||||
[button setTitleColor:BUTTON_DELETE_TEXTCOLOR forState:UIControlStateNormal];
|
||||
[button setTitleShadowColor:BUTTON_DELETE_TEXTCOLOR_SHADOW forState:UIControlStateNormal];
|
||||
@ -363,13 +378,14 @@
|
||||
[button setTitle:BITHockeyLocalizedString(@"HockeyFeedbackListButonDeleteAllMessages") forState:UIControlStateNormal];
|
||||
[button addTarget:self action:@selector(deleteAllMessagesAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
|
||||
[button setFrame: CGRectMake( 10.0f, topGap + 12.0f, self.view.frame.size.width - 20.0f, 42.0f)];
|
||||
|
||||
[cell addSubview:button];
|
||||
|
||||
// status label or shadow lines
|
||||
if (indexPath.section == 0) {
|
||||
UILabel *statusLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 59, self.view.frame.size.width, 28)] autorelease];
|
||||
UILabel *statusLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 6, self.view.frame.size.width, 28)] autorelease];
|
||||
|
||||
statusLabel.font = [UIFont systemFontOfSize:10];
|
||||
statusLabel.textColor = DEFAULT_TEXTCOLOR;
|
||||
|
@ -100,8 +100,10 @@
|
||||
self.navigationItem.rightBarButtonItem.enabled = [self allRequiredFieldsEntered];
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||
return (interfaceOrientation == UIInterfaceOrientationPortrait);
|
||||
#pragma mark - UIViewController Rotation
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark - Private methods
|
||||
|
Loading…
x
Reference in New Issue
Block a user