다음과 같은 시나리오가 있습니다. Xcode를 처음 사용하고 샘플도 수행했습니다. 실제로 SplitView Controller를 사용하여 모든 것이 잘 작동하지만, View Controller에 대해서는 두 개의 ViewController가있는 Navigation Cotroller에서 사용됩니다.SplitView 컨트롤러에서 두 개의보기 컨트롤러 사이에 VALUE 전달
방금 위치를 가져 오는 데 "피커"를 사용했는데 위치를 가져 오면 두 번째보기 컨트롤러에 연결됩니다.하지만 여기에서는 값을 검색하지 않습니다. 다음 코드 조각은
//ViewController1.h
#import "QuerySubmission.h"
@interface MDDetailViewController : UIViewController <UISplitViewControllerDelegate>
{
IBOutlet UIPickerView *pickerView;
NSArray *pickerViewArray;
NSString *setLocation;
}
@property (nonatomic, retain) NSArray *pickerViewArray;
@property (weak, nonatomic) IBOutlet UIPickerView *pickerView;
@property(nonatomic,retain) NSString *setLocation;
@property (strong, nonatomic) id detailItem;
@property (strong, nonatomic) IBOutlet UILabel *detailDescriptionLabel;
- (IBAction)getLocation:(id)sender;
@end
//ViewController1.m
다음- (IBAction)getLocation:(id)sender {
int selectedIndex = [self.pickerView selectedRowInComponent:0];
NSString *message = [NSString stringWithFormat:@"Selected Location: %@",[pickerViewArray objectAtIndex:selectedIndex]];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
QuerySubmission *obj = [[QuerySubmission alloc] initWithNibName:@"QuerySubmission" bundle:nil];
obj.location=[pickerViewArray objectAtIndex:selectedIndex];
//NSLog(@"loc %@", [ pickerViewArray objectAtIndex:selectedIndex]);
//[ pickerViewArray objectAtIndex:selectedIndex];
}
나는 위치 목록을 얻고
를 검색 해요 // ViewController2.h
#import <UIKit/UIKit.h>
#import "MDDetailViewController.h"
@interface QuerySubmission : UIViewController <UISplitViewControllerDelegate>
{
NSString *location;
}
@property(nonatomic,retain) NSString *location;
- (IBAction)querySubmit:(id)sender;
@end
다른 컨트롤러로 이동하는 것과 같습니다. 그냥 "null"을 출력합니다. SplitView Controller를 처음 사용했습니다. 그래서 나는 잘못을 저질렀 는가, 아니면 "대의원" ""에서 무엇인가를 선언해야합니까? 필요가 있습니다.
정말 고맙습니다. –