为整个 UISplitViewController 添加背景
嘿,我想向 UISplitViewController 添加一个背景图像,该图像跨越整个 iPad 屏幕,并且在主视图和详细视图下方可见。
我已经尝试了多种不同的方法,但尚未成功。如果我将它放在 splitView.view 中,它只会覆盖在两个子视图控制器中的所有内容之上。如果我将它放在主视图控制器中,我可以在那里正常执行操作(在其顶部放置 UITableView 等),但它会覆盖详细视图控制器中的所有内容。我尝试的另一条路线是将背景图像放置在它自己的视图控制器中,将整个分割视图控制器放入该视图控制器中,但无论我设置分割视图控制器的 alpha 值,背景仍然是黑色的。
如果有人能指出我让这项工作正常进行,那就太棒了,谢谢!
Hey I want to add a background image to my UISplitViewController that spans the entire iPad screen and is visible underneath both my master and detail views.
I've tried this a number of different ways and have yet to be successful. If I place it in the splitView.view it just overlays on top of everything in both sub-view controllers. If I place it in the master view controller I can do things normally there (place a UITableView on top of it, etc), but it then covers everything in the detail view controller. Another route I tried was to place my background image in it's own view controller the put the entire split view controller inside that view controller, but no matter what I set the alpha of my split view controller the background is still black.
If someone could point me towards getting this working it would be awesome, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
成功了!
首先按照 Apple 的示例以编程方式设置 UISplitViewController: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/iPadControllers/iPadControllers.html
然后添加将 VC 添加到窗口之前的行:
Got it working!
First follow along with Apple's example of setting up a UISplitViewController programmatically here: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/iPadControllers/iPadControllers.html
then add in this line before adding the VC to the window:
我刚刚遇到这个问题,我使用的解决方案是将背景图像放在分割视图控制器视图中,然后将其发送到后面。然后它出现在所有其他内容的后面,只要主视图和详细视图具有清晰的背景颜色,您就可以看到背景图像。
因此,如果 self 是 UISplitViewController 的子类,并且 imgView 是包含背景图像的 UIImageView,那么我只需将其添加到 viewDidLoad() 的 end 处(确保它是在我将视图控制器分配给分割视图控制器)
I just came across this problem and the solution I've used is to put the background image in the split view controllers view and then send it to the back. Then it appears behind all the other content and as long as the master and detail views have a clear background color you can then see the background image.
So if self is a subclass of UISplitViewController and imgView is a UIImageView that contains the background image then I just added this at the end of the viewDidLoad() (making sure it was after I had assigned view controllers to the split view controller)