简体   繁体   English

子类UISplitViewController并设置自定义宽度

[英]Subclass UISplitViewController and set custom width

I'm trying to subclass UISplitViewController to decrease the width of the master. 我正在尝试对UISplitViewController进行子类化以减小主控件的宽度。 I've looked at Matt Gemmell's MGSplitViewController - see Change the width of Master in UISplitViewController - but it looks like way more than I need. 我看过Matt Gemmell的MGSplitViewController-请参阅在UISplitViewController中更改Master的宽度 -但这看起来超出了我的需要。 I just want to decrease the size of the master from 320 to 260 in a way that Apple will accept in the app store. 我只是想将母版的大小从320减小到260,这是Apple可以在应用商店中接受的方式。

I'm new to subclassing anything other than a button, but this is what I'm trying so far, although it currently doesn't do anything. 我是除按钮之外的其他子类的新手,但这是我到目前为止正在尝试的工作,尽管它目前不执行任何操作。 Either I'm way off the mark or I'm missing something simple. 我要么偏离标准,要么错过了一些简单的事情。 How can this be done? 如何才能做到这一点?

Header file: 头文件:

#import <UIKit/UIKit.h>

@interface MYSplitViewController : UISplitViewController

+ (CGFloat)masterColumnWidth;

@end

Implementation file: 实施文件:

#import "SRSplitViewController.h"

@interface SRSplitViewController ()

@end

@implementation SRSplitViewController

+ (CGFloat)masterColumnWidth {
  return 260;
}

@end

I ended up not going this route, and would recommend against trying to subclass UISplitViewController for others. 我最终没有走这条路线,并建议不要尝试为其他人继承UISplitViewController。 It's not a flexible layout so unless you want exactly what it provides out of the box, you are going to run into time-consuming problems. 这不是一个灵活的布局,因此除非您确实想要开箱即用的功能,否则您将遇到耗时的问题。

If you want a side navigation bar similar to the Facebook app, I'd recommend using JASidePanels and placing whatever size and style view controller you want in the left panel. 如果您想要类似于Facebook应用程序的侧面导航栏,我建议您使用JASidePanels并在左侧面板中放置所需的任何大小和样式的视图控制器。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 自定义UISplitViewController - Custom UISplitViewController 自定义 UISplitViewController? - Custom UISplitViewController? iPad:UISplitViewController的自定义工具栏 - iPad: Custom Toolbar for UISplitViewController 以编程方式在UINavigationController中设置UINavigationBar的自定义子类 - Set a custom subclass of UINavigationBar in UINavigationController programmatically 如何设置tableViewIndex的自定义宽度? - How to set custom width of tableViewIndex? Xamarin Monotouch UISplitViewController:如何设置或创建UISplitViewController的委托? - Xamarin Monotouch UISplitViewController: How can I set or create the delegate for UISplitViewController? UIView子类:检测在接口构建器中设置的UIView的大小,该生成器使用所述UIView子类作为自定义类 - UIView Subclass: Detect the size of a UIView set up in Interface Builder which uses said UIView subclass as a custom class 自定义UIView子类背景色未启用自动布局设置 - Custom UIView Subclass background color not being set with Autolayout enabled UISplitViewController - 有没有一种方法可以自动旋转而无需自定义实现? - UISplitViewController - Is there a way to autorotate without custom implementation? 从详细信息视图在UISplitViewController中设置根ViewController - Set root ViewController in a UISplitViewController from the detail view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM