This is a very broad question, not a specific question about a single problem. If you don't want to help with one of these, here is your warning!
I have a View with a pickerWheel
. On this picker, I want to have a list of Cargo ship owners. When I press an OK
Button, I want a UITableView
to be populated by the boats this owner has. Not many, about 5 ships. I want the tableView
to be on the same view as the picker.
When I press a ship in the list, I want to be directed into another view where I can add variable numbers from another view, like carriage load etc.
I know how to make and populate and extract data from the picker, and I DO NOT KNOW how to use this data to somehow populate a table and i do not know how to use a object on a table to link me to a view where i can set different values depending on who sent it.
I am bad at programming, so fullout solutions with code would be great!:)
EDIT: Code i have so far
.h file
#import <UIKit/UIKit.h>
#import "StartupViewController.h"
@interface CargoViewController : UIViewController
@property(strong,nonatomic) IBOutlet UILabel *testLabel; //label I use to test stuff instead of LOG
@property(strong,nonatomic) IBOutlet UIButton *findOwner; //button to summon pickerWheel
@property(strong,nonatomic) IBOutlet UIButton *findShip; //Button to confirm selection in picker and unhide tableView
@property(strong,nonatomic) NSArray *boatOwners; //Array for boat owners.
@property(strong,nonatomic) NSMutableArray *boatsForOwner; //My idea was that when you select a owner, i have a if-else series, so say i select "Bob", I code to add his boats to the array. Does this work? IDK
@property(strong,nonatomic) IBOutlet UITableView *boatsTableView; //Table view
-(IBAction)findOwnerButtonPressed:(id)sender;
-(IBAction)findShipButtonPressed:(id)sender;
@property(strong, nonatomic) IBOutlet UIPickerView *shipOwners; //ship owner picker wheel
@end
.m file:
#import "CargoViewController.h"
@interface CargoViewController ()
@end
@implementation CargoViewController
@synthesize testLabel, findOwner, findShip,shipOwners, boatsTableView;
@synthesize boatsForOwner, boatOwners;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[self getDataFromDensity ];
boatOwners = @[@"owner1", @"owner2", @"owner3"];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void) getDataFromDensity
{
NSString *getData = [[NSUserDefaults standardUserDefaults]
objectForKey:@"globalMathString"]; //Gets a number from another view, wanted to use in the information about boat view later on.
testLabel.text = getData;
[boatsForOwner setValue:@"5" forKey:getData];
}
-(IBAction)findOwnerButtonPressed:(id)sender
{
findShip.hidden = NO;
shipOwners.hidden = NO;
boatsTableView.hidden = YES;
}
-(IBAction)findShipButtonPressed:(id)sender
{
shipOwners.hidden = YES;
findShip.hidden = YES;
boatsTableView.hidden = NO;
}
#pragma mark -
#pragma mark PickerView DataSource
- (NSInteger)numberOfComponentsInPickerView:
(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
return [boatOwners count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView
titleForRow:(NSInteger)row
forComponent:(NSInteger)component
{
return [boatOwners objectAtIndex:row];
}
#pragma mark -
#pragma mark PickerView Delegate
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
inComponent:(NSInteger)component
{
NSString *boatsFromOwner = [boatOwners objectAtIndex:[shipOwners selectedRowInComponent:0]];
}