Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "NewInvoiceViewController.h"
- @interface NewInvoiceViewController ()
- @end
- @implementation NewInvoiceViewController
- @synthesize clientLabel, clientPicker, clientPickerViewContainer, clientStaticCell, clientPickerConstraint;
- - (id)initWithStyle:(UITableViewStyle)style
- {
- self = [super initWithStyle:style];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- - (void)setClientLabelText {
- clientLabel.text = [storedClients objectAtIndex:[clientPicker selectedRowInComponent:0]];
- }
- - (void)showClientPickerUIView
- {
- [UIView animateWithDuration:.5 animations:^{
- clientPickerConstraint.constant = 0;
- [self.view layoutIfNeeded];
- } completion:nil];
- }
- - (void)cancelClientPickerUIView
- {
- [UIView animateWithDuration:.5 animations:^{
- clientPickerConstraint.constant = 260;
- [self.view layoutIfNeeded];
- } completion:nil];
- }
- - (void)doneClientPickerUIView
- {
- [UIView animateWithDuration:.5 animations:^{
- clientPickerConstraint.constant = 260;
- [self.view layoutIfNeeded];
- } completion:^ (BOOL finished){
- if (finished) {
- [self setClientLabelText];
- // Cell will be deselected by following line.
- [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
- }
- }];
- }
- -(void)viewDidLayoutSubviews
- {
- clientPickerConstraint.constant = 260;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- storedClients = [NSArray arrayWithObjects:@"Joe Smith",@"John Doe",@"Bob Johnson",@"Joel Smith", nil];
- // Uncomment the following line to preserve selection between presentations.
- // self.clearsSelectionOnViewWillAppear = NO;
- // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
- // self.navigationItem.rightBarButtonItem = self.editButtonItem;
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (IBAction)cancel:(id)sender{
- [self.navigationController dismissViewControllerAnimated:YES completion:nil];
- }
- - (IBAction)clientSelectCancel:(id)sender {
- [self cancelClientPickerUIView];
- }
- - (IBAction)clientSelectDone:(id)sender {
- [self doneClientPickerUIView];
- }
- // returns the number of 'columns' to display.
- - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
- {
- return 1;
- }
- // returns the # of rows in each component..
- - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
- {
- return [storedClients count];
- }
- -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
- return [storedClients objectAtIndex:row];
- }
- -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
- selectedClient = [storedClients objectAtIndex:row];
- }
- #pragma mark - Table view delegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if([tableView cellForRowAtIndexPath:indexPath] == self.clientStaticCell){
- [self showClientPickerUIView];
- }
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement