标签: xcode4

当我将图像保存到文件时保存的方向是错误的

当我将图像保存到文件时,它以错误的方向保存.

- (void)saveImage:(UIImage *)image:(NSString *)imageName
{
   NSData *imageData = UIImagePNGRepresentation(image);         
   NSFileManager *fileManager = [NSFileManager defaultManager];   
   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
       NSUserDomainMask, YES);
   NSString *documentsDirectory = [paths objectAtIndex:0];         
   NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:
      [NSString stringWithFormat:@"%@.png", imageName]];
   [fileManager createFileAtPath:fullPath contents:imageData attributes:nil];
}
Run Code Online (Sandbox Code Playgroud)

谢谢.

xcode image objective-c xcode4

2
推荐指数
1
解决办法
1752
查看次数

UIButton图像调整大小/缩放以适应

我有一个非常有线的问题,我不知道如何解决它.我正在设置UIButtons框架的动画,当我为它设置动画时,我希望按钮中的图像缩放到与按钮相同的大小.它可以在我的iPhone模拟器上无需任何操作.但是当我在iPad模拟器上运行它时,它不会改变图像大小.我在几个地方添加了[[gissaImg1 imageView] setContentMode:UIViewContentModeScaleToFill]代码,但它没有帮助.

有谁知道什么是错的,以及如何解决这个问题?

//Code to set the image
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%@_small", 
                                              [[itemsForRound objectAtIndex:[[guessItems objectAtIndex:0] intValue]] valueForKey:@"Name"]]];

[self.gissaImg1 setImage:image forState:UIControlStateNormal];
[self.gissaImg1 setImage:image forState:UIControlStateHighlighted];

//Code to animate button
CGRect animateToSpot = (isIphone) ? CGRectMake(0, 0, 480, 320) : CGRectMake(0, 0, 1024, 768);
    [self performSelector:@selector(PlayCorrectSound:) withObject:nil afterDelay:1];
    [[gissaImg1 imageView] setContentMode:UIViewContentModeScaleToFill];
    [UIView animateWithDuration:1.5 delay:0 options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveLinear) animations:^{
        switch (index) {
            case 0:
                [[gissaImg1 imageView] setContentMode:UIViewContentModeScaleToFill];
                [self.gissaImg1 setFrame:animateToSpot];
                [self.view bringSubviewToFront:gissaImg1];
                break;
.......
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios xcode4 ios5

2
推荐指数
1
解决办法
2万
查看次数

切换文件夹时,Reeder Mac app动画列表如何?

最初我的印象是它在插入/删除新行时使用表格行向上/向下动画,但我怀疑它是否正在这样做,因为即使列表中包含数千个项目也是如此流畅(否则会花费很多删除/插入工作的时间).

我是否正确地假设它只是在屏幕底部附加一个新的新闻列表实例,缩小上面的一个而底部的那个扩展以填满空间?

更新:

请看这个我的意思的视频:http://dl.dropbox.com/u/4960327/ReederAnim.mov

cocoa core-animation objective-c appkit xcode4

2
推荐指数
1
解决办法
384
查看次数

在Xcode 4中添加Sparkle框架

我完全陷入了一个可能非常简单的操作......将Sparkle添加到在Xcode 4中创建的项目中.我做了以下操作:

  • 将Sparkle.framework添加到我的项目中(拖放)
  • 添加到"链接二进制文件库"但它生成了此错误:

    dyld:未加载库:@loader_path /../ Frameworks/Sparkle.framework/Versions/A/Sparkle引自:/ Users/me/Library/Developer/Xcode/DerivedData/MyApp-esurnmkwvxcgcxbbrdgsobkoimfv/Build/Products/Release/Myapp .应用程序/内容/ MacOS的/ MyApp的

    原因:找不到图像

  • 删除"链接二进制文件库"
  • 添加到"复制捆绑资源"
  • 在SUUpdater上添加一个实例到mainMenu.xib
  • 是否需要每个配置步骤(创建私钥,上传文件和RSS等...)

当我启动我的应用程序时,我收到一个警告:

Unknown class 'SUUpdater', using 'NSObject' instead. Encountered in Interface Builder file at path /Users/...etcetcetc
Run Code Online (Sandbox Code Playgroud)

显然由于这个警告,更新程序永远不会启动.我错过了什么?

cocoa sparkle xcode4

2
推荐指数
1
解决办法
1647
查看次数

NSArray initWithContentsOfFile返回nil

我试图读取plist文件到NSArray使用initWithContentsOfFile的描述在这里

我的代码看起来像这样

    NSBundle *bundle = [NSBundle mainBundle];
    NSString *plistPath = [bundle pathForResource:
                           @"routes" ofType:@"plist" ];
    routes = [[NSArray alloc] initWithContentsOfFile:plistPath ];
    NSLog:(@"contents of myArray %@", routes);
Run Code Online (Sandbox Code Playgroud)

routes.plist 有一个非常简单的数组结构和2个字符串值

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Root</key>
    <array>
        <string>1</string>
        <string>2</string>
    </array>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

这就是它在xcode中的外观

一切似乎都很好.plistPath使用正确的值初始化,这意味着文件被复制到包中并且可以被重新加载.但是routes = [[NSArray alloc] initWithContentsOfFile:plistPath ];回报0x0价值.我认为这等于nil

我的代码出了什么问题?

objective-c xcode4 ios5 xcode4.2

2
推荐指数
1
解决办法
4209
查看次数

带有$符号的自定义数字键盘

好的,所以我有一个自定义数字键盘工作,并在标签(数字字段)中显示数字为0.00,现在我需要它显示$ 0.00.

NSString *digit = sender.currentTitle;
numberField.text = [numberField.text stringByAppendingString:digit];

NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
[numberFormatter setGroupingSeparator:@""];
[numberFormatter setMaximumIntegerDigits:4];
[numberFormatter setMaximumFractionDigits:2];
[numberFormatter setMaximumFractionDigits:2];

numberField.text = [numberField.text stringByReplacingOccurrencesOfString:@"." withString:@""];
NSDecimalNumber *currency = [[NSDecimalNumber decimalNumberWithString:numberField.text] decimalNumberByDividingBy: [NSDecimalNumber decimalNumberWithString:@"100"]];
NSString *numberFieldFormat = [numberFormatter stringFromNumber:currency];
numberField.text = numberFieldFormat;
Run Code Online (Sandbox Code Playgroud)

我尝试了$%1.2f,但它崩溃了,因为它不能将$符号识别为数字.有人可以帮帮我吗?或者有更好的方法来制作带有$符号的自定义打击垫?

**编辑我正在考虑将numberField设为隐藏标签(alpha 0)并将副本(numberField2)直接放在顶部并通过stringWithFormat运行它.它工作,但我认为可能有一个更清洁的方式.

iphone xcode xcode4

2
推荐指数
1
解决办法
324
查看次数

如何在iphone的视图中的两个分接点之间绘制自动线

在用户点击两个不同点后,我们如何自动绘制线条.这条线应该加入这两个不同的点.

应该使用哪些框架和方法.

谢谢

iphone ios4 ios xcode4

2
推荐指数
1
解决办法
6595
查看次数

XCode 4.3.3在启动运行10.7.4时崩溃

安装Xcode的最新预览版后,我的其他Xcode 4.3.3安装在启动时开始崩溃.我正在运行OS X Lion 10.7.4.这是我打开Xcode几秒钟后发生的崩溃.

    Application Specific Information:
ProductBuildVersion: 4E3002
ASSERTION FAILURE in /SourceCache/IDEFoundation/IDEFoundation-1193/Framework/Classes/Model/Logging/ActivityLog/IDEActivityLogSection.m:666
Details:  Assertion failed: _uniqueIdentifier
Object:   <IDEActivityLogSection: 0x40797e340>
Method:   -dvt_initFromDeserializer:
Thread:   <NSThread: 0x40797e700>{name = (null), num = 19}
Hints:   None
Backtrace:
  0  0x0000000106967b9f -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] (in IDEKit)
  1  0x0000000105e225d5 _DVTAssertionFailureHandler (in DVTFoundation)
  2  0x000000010643aac3 -[IDEActivityLogSection dvt_initFromDeserializer:] (in IDEFoundation)
  3  0x0000000105df4085 -[DVTSimplePlainTextDeserializer decodeObject] (in DVTFoundation)
  4  0x0000000105df4888 -[DVTSimplePlainTextDeserializer decodeObjectList] (in DVTFoundation)
  5  0x000000010643a455 -[IDEActivityLogSection dvt_initFromDeserializer:] (in IDEFoundation)
  6  0x0000000105df4085 -[DVTSimplePlainTextDeserializer decodeObject] (in DVTFoundation)
  7  0x0000000106489b2b +[IDEActivityLogSection sectionWithContentsOfFile:error:] (in …
Run Code Online (Sandbox Code Playgroud)

xcode4

2
推荐指数
1
解决办法
993
查看次数

如何从命令行中找到xcode构建目录?

在从命令行构建Xcode项目时,有很多关于控制放置'build'目录的问题/答案,但是有没有办法获得Xcode使用的路径?

我知道它将文件放在~/Library/Developer/Xcode/DerivedData/APPNAME-xxx/Build/xxx是一些随机字符串的位置.我希望能够到该目录在命令行中获得,这样我可以存档我.app.dSYM文件,并重新签订和我的包.app使用xcrun PackageApplication,这是我目前用它来创建一个在空中安装版本直接形成积-server(哈德森).

automation hudson xcode4

2
推荐指数
2
解决办法
2822
查看次数

cocos2d的声音滑块?

有关如何为cocos2d制作滑块的任何教程可以控制你们推荐的声音吗?一些教程看起来有点阴暗.

iphone cocos2d-iphone xcode4

2
推荐指数
1
解决办法
2398
查看次数