我正在以这种方式处理PDF文件的缩略图:
version :thumb do
process :resize_to_limit => [260, 192]
process :convert => :jpg
process :set_content_type
end
def set_content_type(*args)
self.file.instance_variable_set(:@content_type, "image/jpeg")
end
Run Code Online (Sandbox Code Playgroud)
但是当PDF文件是多页时,它会在一个jpg文件中为所有页面生成缩略图.有没有办法只为第一页制作缩略图?
我正在UIAlertView
使用文本输入.
UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"Save" message:@"Please Enter the Name of PDF" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alertView setAlertViewStyle:UIAlertViewStylePlainTextInput]
Run Code Online (Sandbox Code Playgroud)
当UITextField为空时我想做什么我禁用带有委托功能的OK按钮
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
{
return NO;
}
Run Code Online (Sandbox Code Playgroud)
当用户开始在文本字段中写入内容时,应该启用"确定"按钮.
我正在尝试从UIImage
对象创建渐进式jpeg ,这是我的代码
NSMutableData *data = [NSMutableData data];
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Caches/test.jpg"];
CFURLRef url = CFURLCreateWithString(NULL, (CFStringRef)[NSString stringWithFormat:@"file://%@", path], NULL);
CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url, kUTTypeJPEG, 1, NULL);
CFRelease(url);
NSDictionary *jfifProperties = [NSDictionary dictionaryWithObjectsAndKeys:
(__bridge id)kCFBooleanTrue, kCGImagePropertyJFIFIsProgressive,
nil];
NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:.7], kCGImageDestinationLossyCompressionQuality,
jfifProperties, kCGImagePropertyJFIFDictionary,
nil];
CGImageDestinationAddImage(destination, ((UIImage*)object).CGImage, (__bridge CFDictionaryRef)properties);
CGImageDestinationFinalize(destination);
CFRelease(destination);
Run Code Online (Sandbox Code Playgroud)
这在模拟器中运行时效果很好,但不幸的是在设备上产生了粗糙/块状结果:
关于发生了什么的任何想法?我将恢复使用UIImageJPEGRepresentation
作为最后的手段,我真的需要渐进式JPEG.
我一直试图用jquery从json数据获取facebook页面提要.到目前为止,我已经能够使用我的方法获取页面详细信息,但是当我尝试获取页面的源时,它会给我一个错误,并在控制台中显示"语法错误:无效标签".这是我的代码......
$.getJSON("https://www.facebook.com/feeds/page.php?id=237173582992285&format=json&callback=?", function(results){
console.log(results);
});
Run Code Online (Sandbox Code Playgroud)
我也用整个代码创建了一个jsfiddle.如果需要,请查看 - > http://jsfiddle.net/yZn7N/.我可以看到所有的json数据,如果我去指定的链接,他们确实被提取,我不知道是什么导致无效的标签错误.任何形式的帮助解决或解释为什么会发生这种情况将不胜感激.
我正在使用StoreKit
我的应用程序中的应用程序内购买商店.
我有一个自定义设计,这意味着价格的价值应该是白色和大,货币符号更小,更暗,并与价格值的顶部对齐.
通过使用NSLocale
in SKproduct
的priceLocale
属性和属性中的价格值,我可以毫无问题地获得货币符号price
.
我的问题是知道何时应该在价格之前加上货币符号以及何时将货币符号放在价格之后.
例子:
我可以轻松地使用它NSNumberFormatter
来"开箱即用",但由于我的布局为价值和货币符号定义了不同的风格,我发现自己处于需要更多手动解决方法的位置.
有什么想法吗 ?
是否有可能显示的Facebook UIActivity
中UIActivityViewController
,如果有一个在iOS的默认设置,facebook账号没有设置?现在,如果我进入一些fb帐户 - 我看到fb in UIActivityViewController
,如果没有 - 没有看到.有任何想法吗?
我很想知道谁使用多个核心数据模型以及为什么,有什么好处,我正在开发一个我认为可以从多个模型中受益的应用程序,但我不确定其他好处.
我的即将到来的应用程序将用于iPad和iPhone的另一个版本,iPad有3个主要内容,iPhone只有一个也在iPad上,因此通过将其隔离到不同的核心数据模型可能保持该模型的更改我的两个应用程序将更容易.
虽然我确实有两个实体,但我可以将它们复制或拥有一个大型模型.
有什么建议 ?
无论如何,这当然不是常见情况,其他场景可能会导致您创建多个Core Data模型?
我正在构建自定义布局集合视图.我的收藏中每个项目有2个补充视图.当我想删除一个项目时,我的layoutAttributesForSupplementaryViewOfKind:atIndexPath:
实现将被补充视图调用,该视图应该不再存在.这意味着我得到的索引路径没有正确映射到我的数据源,而且我遇到了一个出界问题.
我做了一些日志记录,第一个例子中的内容是当我们开始使用某些数据时,或者每当我们将项目插入到集合视图中时,计算集合视图的正确和逻辑方式.
第二组日志是在我deleteItemsAtIndexPaths:
从数据源中删除对象之后.
我layoutAttributesForElementsInRect:
看起来像这样:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
NSMutableArray* attributes = [NSMutableArray array];
for (NSInteger i = 0 ; i < [self.myData count]; i++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
NSLog(@"%@ indexPath.row:%d", NSStringFromSelector(_cmd), indexPath.row);
UICollectionViewLayoutAttributes *att = [self layoutAttributesForItemAtIndexPath:indexPath];
[attributes addObject:att];
UICollectionViewLayoutAttributes *att_supp = [self layoutAttributesForSupplementaryViewOfKind:@"one_kind" atIndexPath:indexPath];
[attributes addObject:att_supp];
UICollectionViewLayoutAttributes *linesAttr = [self layoutAttributesForSupplementaryViewOfKind:@"another_kind" atIndexPath:indexPath];
[attributes addObject:linesAttr];
}
return attributes;
}
Run Code Online (Sandbox Code Playgroud)
初始日志(正确和逻辑):
MyApp[18546:70b] layoutAttributesForElementsInRect: indexPath.row:0
MyApp[18546:70b] layoutAttributesForSupplementaryViewOfKind:atIndexPath: indexPath.row:0
MyApp[18546:70b] layoutAttributesForSupplementaryViewOfKind:atIndexPath: indexPath.row:0
MyApp[18546:70b] layoutAttributesForElementsInRect: …
Run Code Online (Sandbox Code Playgroud) 我正在用Core Animation构建一个场景,它看起来类似于旧Apple TV上的屏幕保护程序.连续的图像流(每个a CALayer
)从下到上垂直通过.为实现此目的,在图层的动画移出视图后结束后,它会重新定位到底部,分配新图像并重新生成.这发生在animationDidStop
委托方法中.但是,我注意到如果我在iPad上运行应用程序时截取屏幕截图,则图层永远不会重新定位到底部,并且不会再次显示.我已经解决了这个问题,而且我确信截屏会导致它.这让我觉得拍摄截图对动画时机有影响.所以...
我想在协议中声明一个class func
,我打算从A,B和C类符合这个协议.
B和C继承自A.
基本上我想在B和C中覆盖这个func,同时仍然在A中提供一个实现.
所以,我必须声明我的协议如下:
protocol MyManagedObjectCoolStuff {
static func entityName() -> String
}
Run Code Online (Sandbox Code Playgroud)
然后我在A中有这个:
class A: NSManagedObject { }
class B: A { }
class C: A { }
extension A: MyManagedObjectCoolStuff {
static func entityName() -> String {
return "Animal"
}
}
extension B: MyManagedObjectCoolStuff {
override static func entityName() -> String {
return "Bat"
}
}
extension C: MyManagedObjectCoolStuff {
override static func entityName() -> String {
return "Cat"
}
}
Run Code Online (Sandbox Code Playgroud)
这里的问题很明显,Xcode证实:"类方法会覆盖'最终'类方法".
我该如何解决这个问题?我不能class func …
ios ×7
objective-c ×3
calayer ×1
carrierwave ×1
cocoa ×1
cocoa-touch ×1
core-data ×1
facebook ×1
file-upload ×1
ios6 ×1
ipad ×1
iphone ×1
jquery ×1
jsonp ×1
nslocale ×1
screenshot ×1
storekit ×1
swift ×1
uiactivity ×1
uiimage ×1