내가 다른 ViewControllers 피커 뷰를 사용하여 탐색 하시겠습니까?
그는 소니를 말할 수이 경우에 원하는 이름으로 사람 스크롤
로 이동하기 위해 피커 뷰를 사용하고자하는, 그는 버튼을 밀어 다음은 할당 된 뷰 컨트롤러에 그를 소요 소니. 등등 ..나는 아래에 게시 할 코드를 준 YouTube에서 비디오를 따라 갔다. 튜토리얼 i는 따라 와서 당신이 선택한 것을 알려주는 경고보기를 만들었습니다. 나는 다른 ViewController에 대한 간단한 링크를 위해 이것을 대체하고 싶다.
다른 사람이 수행하는 방법을 안내해 줄 수 있습니까? 나는 초보자이며 가능한 한 최선을 배우려고 노력하고 있으며 이것을 이해하지 못하는 것 같습니다. 내가 코드를 추가 할 필요가 있다고 생각
는 슬래시의 하단에
.h:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource>
@property (weak, nonatomic) IBOutlet UIPickerView *Picker;
- (IBAction)ButtonPressed:(id)sender;
@end
.m:
#import "ViewController.h"
@interface ViewController()
@property (strong, nonatomic) NSArray *array;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSArray *data = [[NSArray alloc] initWithObjects:@"Apple",@"Samsung", @"HTC", @"LG", @"Google", @"Asus", @"Nokia", @"Sony", nil];
self.array = data;
}
#pragma mark Picker Data Source Methods
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return [_array count];
}
#pragma mark Picker Delegate Methods
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [_array objectAtIndex:row];
}
/////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)ButtonPressed:(id)sender {
NSString *select = [_array objectAtIndex:[_Picker selectedRowInComponent:0]];
NSString *tittle = [[NSString alloc] initWithFormat:@"You selected %@:", select];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:tittle message:@"YAY!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
}
//////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@end
이 질문에 찬성표를 던지려면 다음과 같이하십시오. 새로운 사람을 골라라. 모두가 어딘가에서 시작합니다. – Ian