【发布时间】:2016-04-06 07:05:15
【问题描述】:
完全免责声明 - 我对 iOS 还很陌生。我使用带有导航控制器的故事板作为初始入口点创建了一个带有自定义单元格的表格视图,并将我的表格视图作为导航控制器的根视图。当我在模拟器中运行应用程序时,似乎所有内容都被超大/放大了,尽管我的故事板看起来像这样:
我尝试过使用 iPad 和 iPhone,但在这两种设备中,我的故事板都无法正确弹出。我因此实例化了我的根视图控制器:
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//get a pointer to my main storyboard
UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
//instantiate my nav controller + item controller through the storyboard
UINavigationController *nav = [mainStoryBoard instantiateViewControllerWithIdentifier:@"navStoryBoard"];
ItemsViewController *ivs = [mainStoryBoard instantiateViewControllerWithIdentifier:@"tableStoryBoard"];
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = window;
self.window.backgroundColor = [UIColor clearColor];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
// Override point for customization after application launch.
return YES;
}
为什么当我运行我的应用程序时,我的 tableView 不会以正确的大小显示?我是否错误地实例化了我的视图?
【问题讨论】:
-
首先你不需要在didFinishlaunching中写任何一行代码。因为所有设置都在故事板中完成
-
您是否使用自动布局。添加模拟器屏幕截图。
标签: ios objective-c uitableview