I have a UITableView
above a UITextField
. When I select the UITextField
the UITableView
stretches repeatedly. Here is the code I have onViewLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Clock In Time";
CALayer *layer= pickUpWeighCapacityList.layer;
UIColor* uic = UIColorFromRGB(0x336600);
CGColorRef* cgf = uic.CGColor;
layer.borderWidth = 2;
layer.borderColor = cgf;
layer.cornerRadius = 10;
layer.frame = CGRectMake(20.0f, 33.0f, 280.0f, 178.0f);
pickUpWeighCapacityList.dataSource = self;
pickUpWeighCapacityList.delegate = self;
pickUpWeighCapacityList.tableHeaderView = nil;
pickUpWeighCapacityList.tableFooterView = nil;
pickUpWeighCapacityList.frame = CGRectMake(20.0f, 33.0f, 280.0f, 178.0f);
i = 0;
signOutTimeField.placeholder = @"Time to Clock Out of Work";
picker = [[UIDatePicker alloc] init];
signOutTimeField.inputView = picker;
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonSystemItemDone target:self action:@selector(doneEditing)];
self.navigationItem.rightBarButtonItem = rightButton;
[rightButton release];
[picker release];
}
Here's the code I have fo the view's functionality:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 3;
}
How do I get the UITableView
not to stretch? (iOS 4.3. XCode 3.2.6 -- don't judge me).
The solution is non-obvious. In your viewDidLoad
section place the following line:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification object:nil];
Then include the following code in your viewController
:
- (void)keyboardWillHide:(NSNotification *)note
{
[pickUpWeighCapacityList setFrame:
CGRectMake(original-x-coord,original-y-coord,
original-length,original-width)];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.