我有这样的场景:我是 Xcode 的新手,也做过示例。实际上,我使用了 SplitView 控制器,因为它一切正常,但是当谈到详细视图控制器时,我的意思是在带有两个 ViewController 的 Navigation Cotroller 中。
因为我只是使用“选择器”来获取位置,当我按下 get location 时,它会转到第二个视图控制器,但在这里我没有检索到 Vale。这是一段代码
//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 控制器的新手。那么我做错了什么,还是需要在 "delegates """ 处声明任何内容?请做有需要的