今天我更新到Xcode 6.3.2并且我无法运行Clang代码格式化 - 似乎它甚至没有安装.每次我更新Xcode,我都必须重新安装恶意软件和大多数软件包(为什么顺便说一句?),使它们可以在新版本的Xcode上运行.
这次我重新安装了所有软件包(如VVD文件管理器,颜色选择器等),但ClangFormat不起作用 - 它甚至没有出现在"编辑"菜单中.知道为什么吗?
顺便说一句.我试图重启Xcode以及Mac本身:)
编辑(解决方案):
Xcode 6.3.x的解决方案(如果这不起作用,请使用下面的常规解决方案.)
在终端中,输入以下内容:
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add 9F75337B-21B4-4ADC-B558-F9CADF7073A7
Run Code Online (Sandbox Code Playgroud)
一般解决方案
通过终端获取新的UUID:
defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
Run Code Online (Sandbox Code Playgroud)
将新的UUID添加到插件中的DVTPlugInCompatibilityUUIDs键(您的xcplugin文件 - > show package contents - > Contents/Info.plist
迁移到Swift 3后,我有以下方法:
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {}
Run Code Online (Sandbox Code Playgroud)
它给了我警告
实例方法'tableView(tableView:viewForHeaderInSection :)'几乎匹配协议'UITableViewDataSource'的可选要求'tableView(_:titleForHeaderInSection :)'
Fix-it提供将方法设为私有或添加@"nonobjc"注释.如何解决警告?
在Apple的文档中,他们说如果是基于文档的应用程序,你应该恢复调用(restoreStateWithCoder:和encodeRestorableStateWithCoder :)到NSApplication,NSWindow,NSWindowController,然后是整个响应者链(这里).
我想实现这个,但我只在NSWindowController/NSDocument子类中获得恢复调用,而不是NSViews或NSViewControllers.
我创建了一个新的基于文档的应用程序来测试这个(这里),但我只在NSDocument子类中获得了恢复调用,但是没有NSViewController或NSView.
测试项目的代码:
NSDocument子类(恢复工作):
class Document: NSDocument {
override func restoreState(with coder: NSCoder) {
super.restoreState(with: coder)
// Gets called after reopening the app
}
override func encodeRestorableState(with coder: NSCoder) {
super.encodeRestorableState(with: coder)
// Gets called when leaving the window for the first time
}
}
Run Code Online (Sandbox Code Playgroud)
NSViewController子类(恢复不起作用):
class ViewController: NSViewController {
override func restoreState(with coder: NSCoder) {
super.restoreState(with: coder)
// Not called
}
override func encodeRestorableState(with coder: NSCoder) {
super.encodeRestorableState(with: coder)
// Not called
} …Run Code Online (Sandbox Code Playgroud) 是否有可能UIView成为焦点?或者我应该只UIButton为所有可能的视图使用自定义?
我试图覆盖canBecomeFocused但没有发生任何事情.
有什么方法可以从某种颜色(假设它是 [UIColor redColor])创建该颜色的默认突出显示阴影(在这种情况下是某种深红色)。
就我而言,我有一个 UIButton(在 UIBarButton 内部),我想为 UIControlStateHighlighted 状态设置 titleColor,与 UIImage 的默认突出显示颜色相同。请参阅下面的代码:
UIColor *color = [UIColor redColor];
UIColor *highlightedColor = ???;
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[[UIImage imageNamed:@"back-arrow"] imageWithOverlayColor:color] forState:UIControlStateNormal];
[button setImage:[[UIImage imageNamed:@"back-arrow"] imageWithOverlayColor:highlightedColor] forState:UIControlStateHighlighted];
[button setTitle:title forState:UIControlStateNormal];
[button setTitleColor:color forState:UIControlStateNormal];
[button setTitleColor:highlightedColor forState:UIControlStateHighlighted];
button.imageEdgeInsets = UIEdgeInsetsMake(0.f, -5.f, 0.f, 0.f);
Run Code Online (Sandbox Code Playgroud)
如果我没有为 UIControlStateHighlighted 状态设置图像/标题,则按下按钮时仅突出显示图像:

我正在尝试在UIScrollView中创建一个UIView,它只包含一个由UIBezierPath或CG函数淹没的简单网格(行和行).问题是,当我有更大的UIScrollView内容大小(以及更大的子视图)时,在绘制网格期间会分配大量内存(50MB或更多).
UIViewController,它在整个场景中只包含UIScrollView - 在viewDidLoad中添加子视图:
@interface TTTTestViewController()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@end
@implementation TTTTestViewController
-(void)viewDidLoad
{
[super viewDidLoad];
// create the subview
TTTTestView *testView = [[TTTTestView alloc] init];
[self.scrollView addSubview:testView];
//set its properties
testView.cellSize = 50;
testView.size = 40;
// set the content size and frame of testView by the properties
self.scrollView.contentSize = CGSizeMake(testView.cellSize * testView.size, testView.cellSize * testView.size);
testView.frame = CGRectMake(0, 0, self.scrollView.contentSize.width, self.scrollView.contentSize.height);
// let it draw the grid
[testView setNeedsDisplay];
}
@end
Run Code Online (Sandbox Code Playgroud)
仅使用UIBezierPath/CG函数绘制网格的内部视图 - 取决于属性大小(行/列计数)和cellSize(网格中一个单元格的宽度/高度):
#define …Run Code Online (Sandbox Code Playgroud) ios ×3
swift ×3
iphone ×2
apple-tv ×1
clang-format ×1
drawing ×1
focus-engine ×1
ios10 ×1
macos ×1
memory ×1
objective-c ×1
swift3 ×1
tvos ×1
uibezierpath ×1
uibutton ×1
uiscrollview ×1
uitableview ×1
updates ×1
xcode ×1
xcode8 ×1