Iphone 在分割视图控制器上使用色调';s主窗格
我在拆分视图控制器的主窗格中有一个导航控制器。它在导航栏上设置了色调。当此导航控制器显示在拆分视图的popover中时,popover不会以黑色popover样式显示导航项目,而是布局有点混乱,它使用了之前设置的色调: 色调: 在弹出窗口中显示时: 我试着在弹出框中显示之前处理willPresentViewController等以清除色调,并在返回时恢复色调。这几乎可以正常工作,但当切换回横向模式时,在切换回之前,标准的iPad色调在动画期间可见,并且某些导航项上的色调没有正确设置: 在展示popover作品之前清除色调: 但在返回的过程中,按钮处于不一致的状态: 调用Iphone 在分割视图控制器上使用色调';s主窗格,iphone,Iphone,我在拆分视图控制器的主窗格中有一个导航控制器。它在导航栏上设置了色调。当此导航控制器显示在拆分视图的popover中时,popover不会以黑色popover样式显示导航项目,而是布局有点混乱,它使用了之前设置的色调: 色调: 在弹出窗口中显示时: 我试着在弹出框中显示之前处理willPresentViewController等以清除色调,并在返回时恢复色调。这几乎可以正常工作,但当切换回横向模式时,在切换回之前,标准的iPad色调在动画期间可见,并且某些导航项上的色调没有正确设置: 在展示
setNeedsDisplay
等不起作用
当然有更简单的方法吗
编辑:
苹果已经做出回应,这是一个bug,在bugreport.Apple.com上注册为8276014。它应该在4.2中修复(从beta 2开始)。我认为您在SDK中发现了一个非常模糊的错误:)-您应该向Apple提交一份错误报告 我构建了一个测试应用程序,让它重现您的问题:
- 创建拆分窗格项目
- 在主窗格(DetailView)中设置工具栏的色调(红色)
- 设置导航项的色调(为蓝色)
- 添加几个条形按钮项以检查布局是否正常
- 运行应用程序
好的,我已经玩了一个游戏,可以看到发生了什么-尽管我不是100%确定我理解它 我使用git拍摄了我正在工作的第二个项目的快照(主视图工具栏上有一个色调,但弹出窗口上有一个工作布局) 然后我通过在弹出窗口的导航栏上设置色调来打破它 然后,我运行了
git diff
,唯一的更改是(在MainWindow.xib文件中)
这告诉我,你可以通过
1) 在界面生成器中设置样式
2) 手动编辑xib文件以删除指定色调的行
3) 在您的代码中设置(但我不能100%确定此选项是否有效)
希望对你有帮助,谢谢你的挑战
山姆我的最后一个答案完全错了 此代码删除旋转至纵向模式后的色调,并将旋转前的色调设置为横向模式:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:orientation duration:duration];
if (orientation == UIInterfaceOrientationLandscapeLeft ||
orientation == UIInterfaceOrientationLandscapeRight) {
[bar setTintColor:[UIColor redColor]];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIInterfaceOrientationPortrait ||
orientation == UIInterfaceOrientationPortraitUpsideDown) {
[bar setTintColor:nil];
}
}
这位于主视图控制器(包含拆分窗格视图的控制器)中,在横向模式下显示红色条,在纵向模式下显示格式正确的黑色条
你说你在willPresentViewController中试用过,但它不起作用——这对我来说似乎很管用,把它放在这两种方法中。事实证明,这是一个由苹果(bugreport.apple.com上的8276014)确认并在iOS 4.2中修复的错误。我一直找不到任何可以接受的解决办法。拜托,这个小问题一定有解决办法吧?即使是苹果开发者论坛也没有任何结果。很抱歉这篇文章;)我已经玩了一个游戏,应该在灰线之后尝试一个真正的答案:)你说如果你添加色调,DIFF会在xib中显示额外的线。如果这是造成问题的原因,也许通过代码设置色调会起作用。我肯定会尝试,但我认为这是设置色调的事实,而不是设置方式的问题-尽管这只是一种预感:)-也许错误不在布局代码中,而是在导航栏的initWithCoder方法中。好主意——绝对值得一试:)对不起,这一点帮助都没有。首先,我没有使用nibs,其次,在IB工作时将色调设置为默认值的原因是,默认值为零,始终正常工作。显然,我需要使用定制的色调。设置条形样式也不起作用。事实上,这与笔尖或其中的代码无关。很简单,导航栏上的UIColor色调会把popover搞糟。这是否是通过nib完成的并不重要。
+ <int key="IBUIBarStyle">1</int>
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:orientation duration:duration];
if (orientation == UIInterfaceOrientationLandscapeLeft ||
orientation == UIInterfaceOrientationLandscapeRight) {
[bar setTintColor:[UIColor redColor]];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIInterfaceOrientationPortrait ||
orientation == UIInterfaceOrientationPortraitUpsideDown) {
[bar setTintColor:nil];
}
}