这是一个非常宽泛的问题,而不是关于单个问题的具体问题。如果你不想帮助其中的一个,这里是你的警告!选择UITableView里面的对象由UIPickerView选择
我有一个查看与pickerWheel
。在这个选择器上,我想要一个货船船东名单。当我按下OK
按钮时,我想要一个UITableView
由该主人拥有的船只填充。不多,大约有5艘。我希望tableView
与拾取器处于相同的视图。
当我按下一艘船在列表中,我要被引导到另一种观点认为,我可以从其他视图中添加变量数,像马车负荷等
我知道如何制造和填充和提取数据从选择器,我不知道如何使用这些数据以某种方式填充表,我不知道如何使用表上的对象将我链接到一个视图,我可以根据发送它的人来设置不同的值。
我不擅长编程,用代码,使fullout的解决方案将是巨大的:)
编辑:代码,我至今
.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文件:
#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]];
}
你正在读书吗? –
我不学习。我知道什么是随机tuts我在谷歌上找到,ray wenderlich的“Cocos2d for beginners”或什么和从techotopia的Obj-C基础知识 –
所以我没有在这个工作,所以这就是为什么即时通讯如此糟糕 –