【发布时间】:2018-09-27 03:44:15
【问题描述】:
当我单击搜索按钮时,我希望传递数据并从 Search VC(标签索引 4)转到 Classes VC(标签索引 2)。 Search VC 嵌入在 Tab View Controller 中。 Classes VC 嵌入在 Tab View Controller 和 Navigation Controller 中。见附图。
我曾尝试在以下代码中使用 seague,但我丢失了我的 Tab Bar
假设我创建了一个名为 SearchToClass 的海格,从 Search VC 到 Classes VC
#import "Search.h"
#import "Classes.h"
#import "ClassNavigationController.h"
@interface Search(){
NSString *sURL;
}
@end
@implementation Search
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (IBAction)btnSearch:(UIButton *)sender {
NSLog(@"This is the slider %@", lblStart.text);
sURL = @"&Start=";
sURL = [sURL stringByAppendingString:sStartTime];
sURL = [sURL stringByAppendingString:@"&End="];
sURL = [sURL stringByAppendingString:sEndTime];
[self performSegueWithIdentifier:@"SearhToClass" sender:self];
//======== I have also tried the following but couldn't pass the data and I lost the Tab Bar as well======================================
//ClassNavigationController *fromSearch = (ClassNavigationController*)[storyboard instantiateViewControllerWithIdentifier:@"Classes"];
//[fromSearch setModalPresentationStyle:UIModalPresentationFullScreen];
//[self presentViewController:fromSearch animated:NO completion:nil];
//===================================================================
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
Classes *target = segue.destinationViewController;
if ([segue.identifier isEqualToString:@"SearchToClass"]) {
NSLog(@" To ClassesDet sURL : %@", sURL);
target.urlFromSearch = sURL;
}
}
@end
【问题讨论】:
标签: ios objective-c uinavigationcontroller uitabbarcontroller segue