我恢复了我的项目并得到了以下故事标题
在CollectionViewController中我有以下代码,我的问题是当我调用其他页面时,导航栏消失了
<pre> - (void)viewDidLoad {
[super viewDidLoad];
//navigation bar
UIImage *image = [UIImage imageNamed:@"home.png"];
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = CGRectMake(0, 0, 50, 50);
[backButton setImage:image forState:UIControlStateNormal];
UIBarButtonItem *button2 = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = button2;
self.title = @"Welcome User";
marrImages=[[NSMutableArray alloc]init];
mdictImageData=[[NSMutableDictionary alloc]initWithObjectsAndKeys:@"circlshadow_parking.png",@"imageFile",@"Parking",@"Info",nil];
[marrImages addObject:mdictImageData];
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[self navigationController] setNavigationBarHidden:NO animated:YES];
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger lastIndex = [indexPath indexAtPosition:[indexPath length] - 1];
if(lastIndex == 0)
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *myVC = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ParkingMenu"];
myVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:myVC animated:YES];
}
}<code>
答案 0 :(得分:0)
根据Storyboard的设置,你真的应该使用segues而不是手动实例化和呈现视图控制器。
根据故事板截图中的模糊图标,看起来您已成功将其设置为“显示”细分。您的问题很可能存在于其他地方,但这肯定会让您采用更“标准”和最佳实践的做事方式。
要更正此问题,请在Collection View Controller和Parking Menu View Controller之间的segue上设置segue标识符。我们假设segue被识别为“ParkingMenuSegue”。然后,当您需要提供时,请使用:
<强>目标-C:强>
[self performSegueWithIdentifier:@"ParkingMenuSegue" sender:sender];
<强>夫特:强>
performSegueWithIdentifier("ParkingMenuSegue", sender: nil)