窗口的rootViewController是一个navigationController(iOS SDK是7.0。)。
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
MyNavigationController *nav = [[MyNavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = nav;
现在我设置了隐藏在MyNavigationController中的navigationBar:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
self.navigationBarHidden = YES;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
{
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.modalPresentationCapturesStatusBarAppearance = NO;
self.automaticallyAdjustsScrollViewInsets = YES;
}
}
return self;
}
然后在ViewController上添加一个btn:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
self.navigationBarHidden = YES;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
{
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.modalPresentationCapturesStatusBarAppearance = NO;
self.automaticallyAdjustsScrollViewInsets = YES;
}
}
return self;
}
但是btn在状态栏上。我怎么能解决它?