python中的泛型方法(Generic methods in python)
是否有可能在Python中实现泛型方法处理程序,它允许调用不存在的函数? 像这样的东西:
class FooBar: def __generic__method__handler__(.., methodName, ..): print methodName fb = FooBar() fb.helloThere() -- output -- helloThere
Is it possible to implement generic method handlers in python which allow for calling of non-existent functions? Something like this:
class FooBar: def __generic__method__handler__(.., methodName, ..): print methodName fb = FooBar() fb.helloThere() -- output -- helloThere
原文:https://stackoverflow.com/questions/6467461
最满意答案
你如此亲密,只要做到以下几点。
保留split视图布局的细节segues,并为以下方法返回true,并删除其余代码以处理变量
collapseDetailViewController
。func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController, ontoPrimaryViewController primaryViewController: UIViewController) -> Bool { return true }
将以下内容放在Master View控制器中
self.splitViewController!.delegate = self; self.splitViewController!.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible self.extendedLayoutIncludesOpaqueBars = true
将
self.extendedLayoutIncludesOpaqueBars = true
添加到上一个答案中提到的详细视图控制器中。 这应该删除视图控制器上出现的栏。另外如果你想要一些额外的功能,如果你想让你的详细视图在iPad上使用全屏,请添加以下内容。
navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem() navigationItem.leftItemsSupplementBackButton = true
You are so close just do the following.
Keep the split view layout with detail segues and return true for the following method and remove the rest of the code to do with the variable
collapseDetailViewController
.func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController, ontoPrimaryViewController primaryViewController: UIViewController) -> Bool { return true }
Put the following in you Master View controller
self.splitViewController!.delegate = self; self.splitViewController!.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible self.extendedLayoutIncludesOpaqueBars = true
Add
self.extendedLayoutIncludesOpaqueBars = true
to your detail view controller as mentioned by the previous answer. That should remove the bar appearing on your view controllers.Also if you want some extra functionality add the following if you want your detail view to use the full screen on iPad.
navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem() navigationItem.leftItemsSupplementBackButton = true
相关问答
更多-
我找到了一个解决方案,诀窍是删除segue并使用这样的故事板引用: 出于测试和教学目的,我创建了一个完整的测试项目, 可从GitHub获得 。 这演示了使用多个故事板进行详细视图。 11月28日更新:此解决方案有效,但需要iOS 9.完全可以使用另一个UIViewController作为DetailViewController(意味着可以使用模板),只要你删除segue,实现tableView: didSelectRowAtIndexPath并使用示例中的代码。 在后一种情况下,它也适用于iOS 8。 I ...
-
你如此亲密,只要做到以下几点。 保留split视图布局的细节segues,并为以下方法返回true,并删除其余代码以处理变量collapseDetailViewController 。 func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController, ontoPrimaryViewCont ...
-
UISplitViewController不支持此UISplitViewController 。 如果您需要这种UI,通常会创建一个自定义设置来实现此目的。 我使用两个UINavigationController构建一个设置,使用我的App Delegate控制它,然后从那里获取它。 处理轮换时会有一些额外的工作,但在进行自定义操作时可以预料到这一点。 这不应该太难 。 This is not supported by the UISplitViewController. If you need this ...
-
用于iOS 7应用程序的XCode 6中的UISplitViewController(UISplitViewController in XCode 6 for iOS 7 app)[2022-10-16]
我被困在一个类似的问题上。 关闭尺寸类别为我固定。 在故事板的右侧窗格中,单击“显示文件检查器”(纸张图标),并取消选中自动布局设置下方的“使用大小类别”。 I was stuck on a similar issue. Turning off size classes fixed it for me. In the storyboard, on the right pane, click "Show the file inspector" (paper looking icon), and uncheck ... -
UISplitViewController(UISplitViewController)[2022-07-21]
也许这个问题有帮助吗? UISplitViewController必须是应用程序的根视图控制器 Maybe this question will help? A UISplitViewController must be the root view controller of your application -
带有UISplitViewController的UINavigationController(UINavigationController with UISplitViewController)[2023-06-13]
如果您希望将您的应用批准为在App Store上发布,则无法这样做。 如果你使用的是Enterprise发行版,或者只是搞乱了,你可能会得到这个工作: 为您的项目添加一个新视图(NewView) 将视图层次结构从SplitViewController视图复制到NewView中 像正常一样将NewView推入您的导航控制器堆栈 尽管如此,你将无法找到很多帮助,因为这是浪费精力(苹果公司不会允许它)。 If you hope to get your app approved for distribution o ... -
如何在swift中以编程方式创建UISplitViewController(How to create UISplitViewController programmatically in Swift)[2023-06-03]
如果你想用navigationController做,那就试试吧: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { if UIDevice.current.userInterfaceIdiom == .pad { self.window = UIWindow(frame: UIScreen.mainScr ... -
我假设detail["image"]包含的detail["image"]位于应用程序包中(即:不是来自HTTP URL的图像)。 因此,您应该使用UIImage的init(named:)构造函数来加载图像。 像这样的东西: if let myImage = UIImage(named: detail["image"]) { myImageView.image = myImage } 编辑: 这也是您的代码在configureView更好地管理选项和强制转换: func configureView( ...
-
你不应该试着这样做: 拆分视图控制器必须始终是您创建的任何接口的根。 换句话说,您必须始终从UISplitViewController对象安装视图作为应用程序窗口的根视图。 你可以在这里阅读更多相关信息 You should not try to do that: A split view controller must always be the root of any interface you create. In other words, you must always install the vi ...
-
UISplitViewController使用大小类来确定如何显示其主视图和详细视图控制器。 当您的UISplitViewController具有horizontalSizeClass和verticalSizeClass Regular时,它将在同一屏幕上显示Master和Detail视图控制器。 您需要将拆分视图控制器嵌入到容器视图控制器中,以覆盖默认大小类,如我在此处所述 。 您还必须检查设备方向,以便在Compact(纵向)或Regular(横向)横向尺寸等级之间进行分叉: class Contain ...