不知道为什么,我在iOS 7中的搜索栏正在留下一个合适的空间.它在iOS 6中没问题.
我知道它与部分索引有关,因为如果我删除它,空间就会消失,但我不知道如何修复它.有什么想法吗?

我一直试图让这段代码起作用
protocol Shootable
{
func shoot ()
}
protocol Shooter
{
var weapon:Shootable { get set }
}
class Gun:Shootable
{
func shoot() {
}
func someOtherMethod()
{
}
}
class Player:Shooter
{
var weapon:Gun
init ()
{
weapon = Gun()
weapon.someOtherMethod()
}
}
Run Code Online (Sandbox Code Playgroud)
但是编译器告诉我Player不符合Shooter协议.我认为这是因为玩家武器变量是Gun类型,而不是Shootable,即使Gun实现了Shootable.
但后来我改变了这个,现在它起作用了:
protocol Shooter
{
typealias Weapon:Shootable
var weapon:Weapon { get set }
}
Run Code Online (Sandbox Code Playgroud)
我不明白为什么.我认为typealiases只是给了一个类型的另一个名字,我不知道这种能力......
任何人都可以对此有所了解吗?
我正在制作一本带有Core Text的杂志,我正在尝试自动为文本添加连字符.我想我可以用这个功能做到这一点
CFStringGetHyphenationLocationBeforeIndex
Run Code Online (Sandbox Code Playgroud)
但它没有用,我在网上找不到任何例子.
我要做的是设置文本,如果我找到任何连字符位置,我在那里放一个" - "并通过访问器替换文本,所以它调用setNeedsDisplay并从头开始绘制.
- (void) setTexto:(NSAttributedString *)texto {
_texto = texto;
if (self.ctFrame != NULL) {
CFRelease(self.ctFrame);
self.ctFrame = NULL;
}
[self setNeedsDisplay];
}
-(void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
CGContextScaleCTM(context, 1.0, -1.0);
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, NULL, self.bounds);
CTFramesetterRef ctFrameSetterRef = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)(_texto));
self.ctFrame = CTFramesetterCreateFrame(ctFrameSetterRef, CFRangeMake(0, [_texto length]), path, NULL);
NSArray *lines = (__bridge NSArray *)(CTFrameGetLines(self.ctFrame));
CFIndex lineCount = [lines count];
NSLog(@"lines: %d", lines.count);
for(CFIndex idx = 0; idx < lineCount; …Run Code Online (Sandbox Code Playgroud) 我认为之前已经讨论过了,但是找不到适合我的答案。
我正在使用OpenGL ES 2.0开发iPad的2D“绘图”应用程序。
我正在使用“ iPhone 3D编程”一书中介绍的功能创建正交投影矩阵,据我所知,矩阵是正确的。函数调用是这样的:
proj = identity.Ortho(-width/2, width/2, -height/2, height/2, -1.0f, 1.0f);
Run Code Online (Sandbox Code Playgroud)
可以,但是将原点放在视口的中心。我需要从用户处获取触摸信息以进行绘画,因此我希望原点位于左上角。
我知道我并不需要,因为我可以减去(宽度/ 2,高度/ 2),但是如果原点位于TL,一切都会变得更加容易。
所以我尝试了这个:
proj = identity.Ortho(0, width, 0, height, -1.0f, 1.0f);
Run Code Online (Sandbox Code Playgroud)
但这根本不起作用,如果我绘制一个矩形,则在旋转viewModel Matrix时会看到一些线或三角形,这就像它会变形一样。
谢谢。
在我的应用程序(Tres)中,我正在从图像选取器加载图像并将其放在纹理上.这一切在我的所有测试中都运行良好,但是现在,那些带有视网膜显示器的iPad的在线人员抱怨图像变黑了.
我正在查看GL_MAX_TEXTURE_SIZE以确保图像不大于该值.
在这里我设置纹理:
texture_aspect = image.size.width / image.size.height;
CGFloat side = image.size.width;
if(side>GL_MAX_TEXTURE_SIZE)
side = GL_MAX_TEXTURE_SIZE;
UIImage *newImage = [ImageUtils imageWithImage:image scaledToSize:CGSizeMake(side, side)];
image_height = 600.0f;
image_width = image_height * texture_aspect;
if(image_width>600.0f) {
image_width = 900.0f;
image_height = image_width / texture_aspect;
}
NSError* error;
GLKTextureInfo * texture = [GLKTextureLoader textureWithCGImage:newImage.CGImage options:nil error:&error];
if (error) {
NSLog(@"Error loading texture from image: %@",error);
}
Run Code Online (Sandbox Code Playgroud)
这就是我绘制图像的方式:
- (void) dibujaFoto {
self.effect.texture2d0.enabled = GL_TRUE;
[self.effect prepareToDraw];
glEnableVertexAttribArray(GLKVertexAttribPosition);
glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
GLfloat squareVertices[] = { …Run Code Online (Sandbox Code Playgroud) 我知道之前已经讨论过这个问题了,但我不知道这个问题是否随着App Store最近的变化而改变.
我是一名自由开发人员,因此我为许多不同的客户开发应用程序,每个客户都有自己的Apple Developer帐户,可以在App Store上销售他们的应用程序.
我知道我不能自己为我的客户端上传应用程序(不是没有他们的私钥)我正在寻找一种"简单"的方式在App Store上尽可能少地为客户端获取应用程序.
我能想到的选择:
我不知道,有一种方式,不是吗?
编辑: 我似乎找到了一种方法,它在我的回答中有描述.
我正在尝试找到一种方法将CGPoint存储在Core Data数据库中.
在谷歌搜索后,我找到了一个方法,一种方法是有一个实体(在我的情况下是Point2D)与x和y属性.两个浮点数都映射到NSNumber.
问题是,为了获得重点,我有以下Point2D NSManagedObject子类的方法:
- (CGPoint) cgPointValue {
return CGPointMake([self.x floatValue], [self.y floatValue]);
}
Run Code Online (Sandbox Code Playgroud)
它有效,但由于我有很多观点,它似乎在占用CPU.
我想知道是否有更有效的方法来做到这一点.
在AppDelegate.m中使用它来为我的自定义NavBar:
UIImage *NavigationPortraitBackground = [[UIImage imageNamed:@"gradient_main"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UINavigationBar appearance] setBackgroundImage:NavigationPortraitBackground forBarMetrics:UIBarMetricsDefault];
UIImage *barBackBtnImg = [[UIImage imageNamed:@"btn_nav_default.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:barBackBtnImg forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
结果是:

如你所见,按钮似乎重复了.按钮尺寸为61x30.文本没有居中.如果文本较短(例如菜单),则按钮图像被剪切,如果文本较长,则按钮重复.具有较小图标(30x30)的按钮也存在类似问题.按钮显示正常,但我可以点击图像外的按钮:(
xcode objective-c uinavigationcontroller uibarbuttonitem ios