小编Rya*_*ner的帖子

为什么我必须在viewDidLoad中手动设置视图的框架?

我有一个非常基本的设置,在UITabBarController中有一个UINavigationController.我想以编程方式布局该navcontroller的rootViewController视图,但是当我查看viewDidLoad中的self.view.frame时,我得到了这个(例如,在横向中):

1. view frame: {{20, 0}, {748, 1024}} // looks like an odd portrait mode
Run Code Online (Sandbox Code Playgroud)

然后我自动旋转到肖像,我得到了这个:

2. view frame: {{0, 0}, {768, 911}}
Run Code Online (Sandbox Code Playgroud)

然后,当我回到Landscape时,框架现在是这样的:

3. view frame: {{0, 0}, {1024, 655}}
Run Code Online (Sandbox Code Playgroud)

并且进一步的自转事件将在帧值#2和#3之间触发.

为了解决#1的怪异问题,我目前正在viewDidLoad中执行此操作:

if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
    self.view.frame = CGRectMake(0, 0, 768, 911);
} else {
    self.view.frame = CGRectMake(0, 0, 1024, 655);
}
Run Code Online (Sandbox Code Playgroud)

我觉得我在这里显然缺少一些东西.为什么视图的默认框架在自动旋转回相同方向时与框架不匹配?视图框架是否未设置为初始方向?非常困惑...

我应该提一下,上述所有内容,包括我的kludgy hack,都没有在视觉上改变任何东西.我有黑客的原因是,当我将我的子视图布局到这个视图中时,它们将基于我期望它们的位置,即导航栏下方的左上角.

我究竟做错了什么?

更新:关闭视图更改结果#1的所有自动调整内容:

view frame: {{0, 0}, {748, 1024}}
Run Code Online (Sandbox Code Playgroud)

这似乎有点接近,但仍然不匹配#3.

iphone frame uiview viewdidload ipad

31
推荐指数
1
解决办法
2万
查看次数

为什么我的xcode构建总是转到iPad模拟器而不是iPhone模拟器?

我刚从Apple安装了最新的SDK,因此我可以开始学习iPhone/iPad应用开发.但是,我有一个愚蠢的问题:我的所有构建都在iPad模拟器而不是iPhone模拟器中运行,我不知道如何更改它.

iphone xcode cocoa ipad

7
推荐指数
2
解决办法
9275
查看次数

这个查询出了什么问题?EXPLAIN对我来说很好看

我正在浏览一个应用程序,并试图优化一些查询,我真的在努力解决其中的一些问题.这是一个例子:

SELECT `Item` . * , `Source` . * , `Keyword` . * , `Author` . *
FROM `items` AS `Item`
JOIN `sources` AS `Source` ON ( `Item`.`source_id` = `Source`.`id` )
JOIN `authors` AS `Author` ON ( `Item`.`author_id` = `Author`.`id` )
JOIN `items_keywords` AS `ItemsKeyword` ON ( `Item`.`id` = `ItemsKeyword`.`item_id` )
JOIN `keywords` AS `Keyword` ON ( `Keyword`.`id` = `ItemsKeyword`.`keyword_id` )
JOIN `keywords_profiles` AS `KeywordsProfile` ON ( `Keyword`.`id` = `KeywordsProfile`.`keyword_id` )
JOIN `profiles` AS `Profile` ON ( `Profile`.`id` = `KeywordsProfile`.`profile_id` …

mysql optimization performance

5
推荐指数
1
解决办法
649
查看次数

标签 统计

ipad ×2

iphone ×2

cocoa ×1

frame ×1

mysql ×1

optimization ×1

performance ×1

uiview ×1

viewdidload ×1

xcode ×1