标签栏向下移到模拟器的边界之外 [英] The tab bar is shifted down outside the borders of the simulator
问题描述
我创建了一个空项目(XCode 4.2 IOS SDK 5),向其中添加了一个新视图,并使其成为appDelegate内的根视图控制器,因此当该应用运行时,它会正确显示该视图,我在视图中添加了一个tabbarcontroller,在新创建的视图中为其创建了IBOutlet,并将此行添加到视图的viewDidLoad方法中:
I have created an empty project (XCode 4.2 IOS SDK 5), I have added a new view to it and make it the root view controller inside the appDelegate, so when the app runs, it displays that view correctly, however, I added a tabbarcontroller to the view, created an IBOutlet for it inside the newly created view, and added this line to viewDidLoad method of the view:
[self.view addSubview:self.tabController.view];
因此选项卡栏在iphone模拟器中正确加载,但是有一个我无法解决的小问题:该选项卡栏的一半向模拟器下移,这阻止了选项卡标题的出现,如以下屏幕截图所示:
so the tab bar loads correctly in the iphone simulator, but with a little problem that I couldn't fix: half of that tab bar is shifted down the simulator which prevents tabs' titles from appearing, exactly as in the following screenshot:
如何解决此问题?
推荐答案
最有可能是因为状态栏.但是,由于插入控制器的子视图可以是任意大小,因此最通用的解决方案是:
Most likely it's because of status bar. But, because subview where you inserting controller can be any size, most universal solution is:
[tabController.view setFrame:self.view.bounds];
(假设self.view-是在其中添加视图的视图)
(assuming self.view - is the view, where you adding it)
这篇关于标签栏向下移到模拟器的边界之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!