2012-02-19 1 views
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; 
} 
+0

코딩 즐길 수 있습니다. – Mrunal

+0

안녕하세요, 기본적으로 약 3 드롭 다운 메뉴가있는 페이지를 좋아하고 드롭 다운 메뉴에서 목록에서 무언가를 선택할 때 가능한 경우 테이블보기로 이동하고 싶습니다. –

+0

이러한 이미지와 같은 몇 가지 http://imgur.com/pugk8&yxdB1 http://imgur.com/pugk8&yxdB1#1 –

답변

0

이 단계에 따라 내 코드를 heres 도움이 될 수 있습니다, 각 pickerview의 선택에

  • 를 다시 한 가변 배열
  • 때마다 해당 데이터를 추가하려면 해당 데이터가있는 테이블보기 (변경 가능한 배열)
  • 선택한 데이터가 표 목록에 추가됩니다.

은 당신의 요구 사항을 이해하기 위해 자세한 내용을 알려주세요 :)

+0

안녕하세요 고맙습니다. 거기에 ia 초급자 코드 수있는 기회가있다 :) –