我的 iOS 应用项目有问题。我想将我的 SearchViewController 的值传输到我的 ResultGeneralInfoViewController。没有错误或问题,但它不起作用。
这是我的 SearchViewController.m 中的代码
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *item = [searchResults objectAtIndex:[indexPath row]];
ResultGeneralInfosViewController *detailViewController = [ResultGeneralInfosViewController alloc];
detailViewController.companyName = [item objectForKey:@"companyName"];
NSLog([item objectForKey:@"companyName"]);
}
结果GeneralInfoViewController.h
@interface ResultGeneralInfosViewController : UIViewController {
NSString *companyName;
}
@property NSString *companyName;
@property (weak, nonatomic) IBOutlet UILabel *companyNameLabel;
和 ResultGeneralInfoViewController.m
@implementation ResultGeneralInfosViewController
@synthesize companyName;
//Outlets
@synthesize companyNameLabel;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
companyNameLabel.text = self.companyName;
}
有任何想法吗?