Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UITableView.appearance().separatorStyle不工作_Uitableview_Swift_Uiappearance - Fatal编程技术网

UITableView.appearance().separatorStyle不工作

UITableView.appearance().separatorStyle不工作,uitableview,swift,uiappearance,Uitableview,Swift,Uiappearance,在我的AppDelegate中,我设置了UITableView的外观,如背景和行高等。但不知何故,它不适用于分隔符样式。有没有什么原因导致它不工作或者这是一个bug?我可以使用tableView.separatorStyle=.None在ViewController本身中设置separatorStyle 我的AppDelegate中的代码: func application(application: UIApplication, didFinishLaunchingWithOptions lau

在我的AppDelegate中,我设置了UITableView的外观,如背景和行高等。但不知何故,它不适用于
分隔符样式
。有没有什么原因导致它不工作或者这是一个bug?我可以使用
tableView.separatorStyle=.None在ViewController本身中设置
separatorStyle

我的AppDelegate中的代码:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    application.statusBarHidden = true

    UIToolbar.appearance().barTintColor = UIColor.grayColor()

    UITableView.appearance().backgroundColor = UIColor.blackColor()
    UITableView.appearance().rowHeight = 40
    UITableView.appearance().separatorStyle = .None

    UITableViewCell.appearance().backgroundColor = UIColor.clearColor()

    return true
}
奇怪的是,
separatorColor
确实有效

编辑:

当我选中
UITableView
时,会显示:

// Appearance

var sectionIndexMinimumDisplayRowCount: Int // show special section index list on right when row count reaches this value. default is 0
@availability(iOS, introduced=6.0)
var sectionIndexColor: UIColor? // color used for text of the section index
@availability(iOS, introduced=7.0)
var sectionIndexBackgroundColor: UIColor? // the background color of the section index while not being touched
@availability(iOS, introduced=6.0)
var sectionIndexTrackingBackgroundColor: UIColor? // the background color of the section index while it is being touched

var separatorStyle: UITableViewCellSeparatorStyle // default is UITableViewCellSeparatorStyleSingleLine
var separatorColor: UIColor! // default is the standard separator gray
@availability(iOS, introduced=8.0)
@NSCopying var separatorEffect: UIVisualEffect? // effect to apply to table separators
有点奇怪,因为它在注释
外观下。标题与separatorColor相比也没有什么不同。

这没有什么“奇怪”或“不工作”或“问题”。并不是所有的东西都是外观代理兼容的。查看标题:

@property (nonatomic) UITableViewCellSeparatorStyle separatorStyle; // default is UITableViewCellSeparatorStyleSingleLine
@property (nonatomic, retain) UIColor *separatorColor UI_APPEARANCE_SELECTOR; // default is the standard separator gray

注意到什么了吗<代码>分隔颜色
标记为
UI\u外观\u选择器
<代码>分隔符样式
不可用。这意味着您可以将
separatorColor
与外观代理一起使用,而不能将
separatorStyle
与外观代理一起使用。

我也检查了这一点,但在Swift中,它没有显示
UI\u外观\u选择器,或者我看的是错误的部分吗?(我用Swift中可见的问题编辑了我的问题)不,它不会出现在标题的Swift翻译中,但这不是重点。关键是我在回答中所说的——并不是所有的东西都与外观代理兼容:特别是,分隔符颜色是,分隔符样式不是。这是事实。不是虫子。事实。标题是否告诉您这一事实并不重要;这仍然是事实。我只是用标题来说明这是事实。冷静点,我从来没有说过你错了,甚至不同意你的观点。当两种方法似乎相同时,质疑某件事是否属于犯罪行为?显然,试图理解某些事情值得投反对票。这对新手来说真是太棒了!当我使用Swift时,你的方法无法找出为什么它不起作用。所以,每当有些东西不起作用时,我只能假设不是所有的东西都兼容,然后继续前进,放弃并使用另一种方式。很好的教训。