0
我有這樣的代碼,我在Xcode 4.2上做了一個標籤式應用程序,它的工作原理完美,但我希望它是一個下拉菜單中的選擇器視圖,但我不確定是什麼代碼我將需要添加你們可以幫助我的繼承人代碼使用UIPickerview
.h
#import <UIKit/UIKit.h>
@interface FirstViewController : UIViewController {
IBOutlet UIPickerView *pickerView;
NSMutableArray *list;
IBOutlet UILabel *picklabel;
}
@end
.m
#import "FirstViewController.h"
@implementation FirstViewController
-(NSInteger)numberOfComponentsInPickerview:(UIPickerView *)thePickerView {
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
return [list count];
}
-(NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { return [list objectAtIndex:row];
}
-(void)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row inComponent:(NSInteger)component {
NSString *string = [NSString stringWithFormat:@"you selected: %@" , [list objectAtIndex:row]];
picklabel.text = string;
}
- (void)viewDidUnload
{
[super viewDidUnload];
list = [[NSMutableArray alloc] init];
[list addObject:@"Giraffe"];
[list addObject:@"Water Bottle"];
[list addObject:@"spinning Fan"];
[list addObject:@"Hariy Monkey"];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
請提供更多的細節,以瞭解您的需求。 – Mrunal 2012-02-19 13:07:33
嗨,我基本上喜歡有一個約3下拉菜單的頁面,當我從下拉菜單中的列表中選擇一些我希望它可以去一個表視圖,如果這是可能的? – 2012-02-19 13:12:20
有些事像這些圖片http://imgur.com/pugk8&yxdB1 http://imgur.com/pugk8&yxdB1#1 – 2012-02-19 13:15:39