Skip to content

Commit 6ca3770

Browse files
committed
fixed conflict
2 parents bb40b89 + 40bfafe commit 6ca3770

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

iOS/Classes/HKFormController.m

+23-11
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
#import "HKFormTableViewCell.h"
2828

29-
@interface HKFormController (Private)
29+
@interface HKFormController ()
30+
31+
@property (assign) UIEdgeInsets originalInset;
3032

3133
- (HKFormTableViewCell *)cellWithTextField:(UITextField *)textField;
3234

@@ -90,14 +92,16 @@ - (void)didReceiveMemoryWarning
9092
- (void)viewDidLoad
9193
{
9294
[super viewDidLoad];
93-
95+
9496
[self setupEnclosingNavigationController];
9597

9698
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShowNotification:) name:UIKeyboardDidShowNotification object:nil];
99+
100+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHideNotification:) name:UIKeyboardDidHideNotification object:nil];
97101
}
98102

99103
- (void)setupEnclosingNavigationController
100-
{
104+
{
101105
self.title = [self.definition objectForKey:@"title"];
102106
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
103107
target:self
@@ -185,11 +189,12 @@ - (void)ensureTableViewVisible
185189
CGRect tframe = self.tableView.frame;
186190
CGRect kframe = [self.view convertRect:self.currentKeyboardFrame fromView:nil];
187191
CGRect intersect = CGRectIntersection( tframe, kframe );
188-
192+
189193
if ( CGRectIsNull( intersect ) )
190194
return;
191195

192-
self.tableView.contentInset = UIEdgeInsetsMake( 0.0, 0.0, intersect.size.height, 0.0 );
196+
self.originalInset = self.tableView.contentInset;
197+
self.tableView.contentInset = UIEdgeInsetsMake( self.tableView.contentInset.top, 0.0, intersect.size.height, 0.0 );
193198
}
194199

195200
- (void)ensureTableViewCellVisible:(UITableViewCell *)tableViewCell
@@ -248,15 +253,15 @@ - (BOOL)ensureRequiredFieldsFilled
248253
cancelButtonTitle:[self localize:@"OK"]
249254
otherButtonTitles:nil];
250255
NSInteger tag = ( HK_FORM_TAG_OFFSET + section * 1000 + row );
251-
256+
252257
[alertView show];
253258

254259
while ( alertView.visible && [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]] )
255260
{
256261
}
257262

258263
[alertView release];
259-
264+
260265
field = (UITextField *) [self.view viewWithTag:tag];
261266

262267
if ( field )
@@ -280,7 +285,7 @@ - (IBAction)handleDone:(id)sender
280285
if ( [self ensureRequiredFieldsFilled] )
281286
{
282287
[self.parentViewController dismissViewControllerAnimated:YES completion:nil];
283-
288+
284289
[[NSNotificationCenter defaultCenter] postNotificationName:HK_FORM_NOTIFICATION_DONE_EDITING object:self];
285290
}
286291
}
@@ -312,10 +317,17 @@ - (void)keyboardDidShowNotification:(NSNotification *)notification
312317
[self ensureTableViewCellVisible:[self cellWithTextField:self.currentTextField]];
313318
}
314319

320+
321+
- (void)keyboardDidHideNotification:(NSNotification *)notification
322+
{
323+
self.tableView.contentInset = self.originalInset;
324+
}
325+
326+
315327
#pragma mark UITextFieldDelegate Methods
316328

317329
- (void)textFieldDidBeginEditing:(UITextField *)textField
318-
{
330+
{
319331
_editing = YES; self.currentTextField = textField;
320332

321333
[self ensureTableViewCellVisible:[self cellWithTextField:self.currentTextField]];
@@ -338,7 +350,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
338350
}
339351

340352
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
341-
{
353+
{
342354
return [[[[self.definition objectForKey:@"sections"] objectAtIndex:section] objectForKey:@"children"] count];
343355
}
344356

@@ -366,7 +378,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
366378

367379
cell.selectionStyle = UITableViewCellSelectionStyleNone;
368380

369-
cell.formLabel.text = [[self localize:[child objectForKey:@"title"]] lowercaseString];
381+
cell.formLabel.text = [self localize:[child objectForKey:@"title"]];
370382

371383
cell.formField.placeholder = [NSString stringWithFormat:@"%@%@%@", [self localize:[child objectForKey:@"placeholder"]], ( required ? @"" : @" " ), ( required ? @"" : [self localize:@"(optional)"] )];
372384

0 commit comments

Comments
 (0)