有没有人在Xcode 6和iOS 8上获得iCloud核心数据同步设置?(希望这不是一个重复的帖子)
iCloud核心数据存储选项在哪里?
我记得Core Data有一个名为Core Data storage的额外存储选项,但现在在Xcode 6中,当我在Xcode 6中启用iCloud切换时,它似乎只显示键值和文档存储.
到目前为止,我不知道我是否正确设置了Core Data iCloud.
Xcode似乎已在iOS Developer Portal中设置了iCloud容器:
iCloud.com.xxxxxx.xxxxxxxx (note: I've replaced the actual strings with xxxx here)
Run Code Online (Sandbox Code Playgroud)
我的Xcode 6 iCloud"服务"列表显示旁边没有刻度:
我们现在应该使用哪一个,因为它没有将"核心数据"列为存储选项?
在"服务"正下方的"容器"中,它显示以下灰色选项:
我无法选择任何选项,它似乎迫使我"使用默认容器".
最后,Xcode似乎显示为:
因此,通过Xcode自己的自动化流程,它为我设置了一切.
好的,所以我四处阅读并注意到这里写的iCloud堆栈:
https://github.com/mluisbrown/iCloudCoreDataStack
我已经采取了必要的代码并尝试适应我的核心数据管理器单例:
+ (id)sharedModel;
+ (ALAssetsLibrary *)sharedLibrary;
@property (nonatomic, readonly) NSManagedObjectContext *mainContext;
@property (nonatomic, readonly) NSPersistentStoreCoordinator *storeCoordinator;
- …Run Code Online (Sandbox Code Playgroud) 再次使用Swift,我错过了什么吗?
我有这条线:
self.itemDescription?.setContentCompressionResistancePriority(UILayoutPriorityRequired, forAxis: UILayoutConstraintAxis.Vertical);
Run Code Online (Sandbox Code Playgroud)
但是Xcode给了我一个错误:
Undefined symbols for architecture i386: "_UILayoutPriorityRequired"
Run Code Online (Sandbox Code Playgroud)
另一个斯威夫特的怪癖?
我有一个相当复杂的collectionView单元格,我注意到如果我在我的collectionView上滚动得非常快,它会崩溃应用程序.
我得到的错误之一是:
negative or zero sizes are not supported in the flow layout
Run Code Online (Sandbox Code Playgroud)
我注意到如果我只是返回一个浮点值,例如500,在我的UICollectionView sizeForItemAtIndexPath:方法中,它不会崩溃.
我的集合视图具有动态单元格高度.
我正在sizeForItemAtIndexPath:使用此库在我的方法中解析HTML Attributed字符串:
https://github.com/mmislam101/HTMLAttributedString
任何人都知道是什么原因导致上述错误消息特别发生?
我在Bugsense报告中看到的与此崩溃有关的另一个错误是:
- [__ NSArrayM objectAtIndex:]:索引2超出边界[0 .. 1]
当我滚动得太快时会发生这种情况= /
Bugsense stacktrace显示崩溃顺序方法调用是:
1)collectionView:layout:sizeForItemAtIndexPath:
2)calculateFeedCellHeightForIndexPath :(这是我自己的方法之一,而不是Apple的方法)
3)dynamicHeightForHTMLAttributedString:UsingWidth:AndFont :(这是我自己的方法之一,而不是Apple的方法)
4)HTMLAttributedString attributionStringWithHtml:andBodyFont:第35行
5)HTMLAttributedString attributionString第79行
6)scrollViewDidScroll:第174行
7)setFeedFooterHeight:animated:第124行
我的setFeedFooterHeight:animated:方法是:
-(void)setFeedFooterHeight:(CGFloat)newHeight animated:(BOOL)animated
{
footerHeightConstraint.constant = newHeight;
if(animated)
{
[UIView animateWithDuration:0.35 animations:^{
[self layoutIfNeeded]; // <------ crash on this line it seems
}];
}
else
{
[self.feedFooterView layoutIfNeeded];
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我直接从Xcode运行应用程序而不是上面的Testflight时,Xcode在上面的步骤5停止,这产生了这段代码:
- (NSAttributedString …Run Code Online (Sandbox Code Playgroud) 我可能会因此而受到抨击.
我想知道是否有人知道在iPhone应用程序中加载APNG(动画PNG)的任何方法?
我不是在谈论添加为多个PNG图像NSArray的UIImages一个UIImageView.我已经可以使用这种方法,但这需要多个PNG图像.
我在谈论一种名为APNG(http://en.wikipedia.org/wiki/APNG)的特殊PNG格式,它只包含1个PNG文件但具有动画元数据.
我发现这个名为AVAnimator的库:http://www.modejong.com/AVAnimator/index.html ,据称可以加载APNG格式,但许可证价格为475美元,而且该库似乎是几年前的(iOS 4) ).
我还读到Apple iOS 8 Safari以及Yosemite Safari已经内置了对APNG的支持.
我真的不想仅仅使用UIWebView来显示APNG文件.它有效,我测试了它,但我不认为这是理想的.
我希望有一些未被发现的新iOS SDK让我们将APNG加载到我不知道的应用程序中,也许你们可能知道.
Line应用程序(http://line.me/en/)如何做到这一点?他们似乎有动画的PNG为他们的"贴纸".
我正在尝试向ImageView添加投影.另一个Stackoverflow答案似乎是使用画布和位图等,比它需要的方式更复杂.
在iOS上我会做这样的事情:
myImageView.layer.shadowColor = [UIColor redColor].CGColor;
myImageView.layer.shadowRadius = 5;
myImageView.layer.shadowOffset = CGRectMake(0, 5);
Run Code Online (Sandbox Code Playgroud)
它会渲染阴影,无论阴影是否应用于视图,图像或文本.
我试过在Android上做同样的事情,但它只是拒绝工作:
birdImageView = new ImageView(context);
birdImageView.setImageResource(R.drawable.yellow_bird);
Paint paint = new Paint();
paint.setAntiAlias(true);
birdImageView.setLayerType(LAYER_TYPE_SOFTWARE, null);
paint.setShadowLayer(5, 0, 5, Color.argb(255, 255, 0, 0));
birdImageView.setLayerPaint(paint);
Run Code Online (Sandbox Code Playgroud)
我的鸟图像上根本没有看到任何预期的红色阴影.
难道我做错了什么?
假设我想要这样的投影:
我是否必须使用Android 5.0和新的Elevation api(http://developer.android.com/training/material/shadows-clipping.html)?
但如果要使用新的API,那么根据当前的人口统计数据(http://www.droid-life.com/2016/02/02/android-distribution-february-2016/),超过50%的用户不会能够使用该应用程序.
T_T
我正在尝试以编程方式(不使用XML文件)在Android中创建自定义子视图(这就是我在iOS中所称的),它基本上是一些基本视图(标签,按钮,文本字段等)放在一个可重用的子视图中所以我可以在我UIViewControllers或ActivityAndroid中使用它.
我不知道Android中的正确术语是什么.似乎有一百万种不同的术语.
自定义视图,ViewGroups,布局,窗口小部件,组件,无论您想要调用它.
在iOS中,这样做就像这样:
@interface CustomView : UIView
@property (nonatomic, strong) UILabel *message;
@property (nonatomic, strong) UIButton *button;
@end
Run Code Online (Sandbox Code Playgroud)
@implementation CustomView
-(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if(self)
{
[self initViews];
[self initConstraints];
}
return self;
}
-(void)initViews
{
self.message = [[UILabel alloc] init];
self.button = [[UIButton alloc] init];
[self addSubview:self.message];
[self addSubview:self.button];
}
-(void)initConstraints
{
id views = @{
@"message": self.message,
@"button": self.button
};
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[message]|" options:0 metrics:nil views:views]];
[self …Run Code Online (Sandbox Code Playgroud) 我有一个名为"server.js"的Node.js文件.
在脚本中,我使用以下内容打开一些文件:
var certPem = fs.readFileSync('cert_and_key_dev.pem', encoding='ascii');
Run Code Online (Sandbox Code Playgroud)
使用bash shell,如果我进入server.js所在的目录,并运行命令:
[mybashshell] $ node server.js
它有效,我没有错误.服务器启动并运行.
现在,当我在server.js文件所在的目录下,然后再次运行相同的shell命令来启动我的服务器.
它抱怨我的"cert_and_key_dev.pem"的文件路径被破坏了.
我没想到会发生这样的事情.我虽然正在执行的脚本文件中使用的路径应该是相对于脚本文件的,而不是我执行bash shell命令的位置.
有任何想法吗?
我这里有一个复杂的场景.
我有一个Web服务器将JSON数据发送回我的应用程序,其中一个数据是HTML文本,例如json:
...
{
id: 3,
name: "Content Title",
description: "<p>This is a paragraph block</p><p>This is another paragraph</p>",
}
Run Code Online (Sandbox Code Playgroud)
您可能知道,HTML标记文本会增加另一层复杂性,因为HTML标记会修改实际文本的高度.
所以像这样的字符串:
"Hello World"
Run Code Online (Sandbox Code Playgroud)
可能只有10像素高的普通字符串,但如果格式如下:
"<h1>Hello World</h1>"
Run Code Online (Sandbox Code Playgroud)
的真实高度可以潜在地是大于10像素高.
我想知道的是如何计算出真正的高度?
这就是我用归因字符串计算UILabel高度的方法,但它似乎只给出了适合文本像素的高度,而不是实际的HTML元素块大小:
-(CGFloat)dynamicHeightForHTMLAttributedString:(NSString *)dataString UsingWidth:(CGFloat)width AndFont:(UIFont *)font
{
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font
forKey:NSFontAttributeName];
NSMutableAttributedString *htmlString =
[[NSMutableAttributedString alloc] initWithData:[dataString dataUsingEncoding:NSUTF8StringEncoding]
options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute:[NSNumber numberWithInt:NSUTF8StringEncoding]}
documentAttributes:NULL error:nil];
[htmlString addAttributes:attrsDictionary range:NSMakeRange(0, htmlString.length)];
CGRect rect = [htmlString boundingRectWithSize:(CGSize){width, CGFLOAT_MAX} options:NSStringDrawingUsesLineFragmentOrigin context:nil];
CGSize size = rect.size;
return ceilf(size.height);
}
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?
我正在看Overcoat图书馆,我收集的是一个扩展Mantle图书馆的图书馆.
地幔:https://github.com/Mantle/Mantle/ 大衣:https://github.com/gonzalezreal/Overcoat
Mantle和Overcoat github页面一直提到创建Mantle模型,但我想知道如何生成Mantle模型?我是否手动输入或者是否使用Xcode xcdatamodel文件以可视方式构建它,然后生成子类+之后修改该文件?
在Core Data中,使用Interface Builder在xcdatamodel文件中创建实体,然后使用Xcode的Editor> Create NSManagedObject子类.
我们是否为Mantle做同样的事情,然后从NSManagedObject更改为MTLModel?
当我们决定更新xcdatamodel文件中的Core Data实体时会发生什么?如果我们再次重新生成模型文件,我们不是必须将所有这些更改重新添加到NSManagedObject类中吗?
超级混淆了这个过程.
我没有使用Swift那么多,但是来自Objective C,有一些关于Swift的东西,这是一个PITA来解决我的问题.
在iOS编程中,我们有animateWithDuration:方法,它是UIView的一部分.
所以我尝试使用Xcode的自动完成并开始输入:
UIView.animateWith
Run Code Online (Sandbox Code Playgroud)
自动填充显示:
UIView.animateWithDuration(duration: NSTimeInterval, animations: () -> Void)
Run Code Online (Sandbox Code Playgroud)
然后我选中了"持续时间"字段,然后输入一个数字:
UIView.animateWithDuration(0.5, animations: () -> Void)
Run Code Online (Sandbox Code Playgroud)
然后我再次选中了动画块,然后像在Objective C中一样按下输入,Xcode现在显示:
UIView.animateWithDuration(0.5, animations: { () -> Void in
code
})
Run Code Online (Sandbox Code Playgroud)
所以我最后一次用我的代码替换"代码":
UIView.animateWithDuration(0.5, animations: { () -> Void in
self.customView?.transform = CGAffineTransformMakeTranslation(0.0, 0.0);
})
Run Code Online (Sandbox Code Playgroud)
那时Xcode然后给我错误:
无法使用类型为'(FloatLiteralConvertible,animations :() - > Void)的参数列表调用'animateWithDuration'
我不明白.这是Xcode为我生成的自动完成代码,为什么它会给我一个错误?
我注意到如果做一个简单的声明,如:
UIView.animateWithDuration(0.5, animations: { () -> Void in
var num = 1 + 1;
})
Run Code Online (Sandbox Code Playgroud)
它没有给我任何错误.
任何人的想法?
奇怪的Rails问题.
我有一个Book实体,用户可以Love一本书.
我所有的其他型号都很好,通过了所有的测试,但在生成新Love模型和设置灯具后,我得到了大量的这些错误:
ActiveRecord::Fixture::FixtureError: table "books" has no column named "loves".
Run Code Online (Sandbox Code Playgroud)
我不知怎的认为这与Rails中的保留关键字有关呢?
Love任何机会都是保留关键字?
我在这个页面上搜索过:
https://reservedwords.herokuapp.com/
这个词love没有结果.
class CreateLoves < ActiveRecord::Migration[5.0]
def change
create_table :loves do |t|
t.references :book, foreign_key: true
t.references :sender, foreign_key: true
t.references :receiver, foreign_key: true
t.timestamps
end
end
end
Run Code Online (Sandbox Code Playgroud)
class Love < ApplicationRecord
belongs_to :book
belongs_to :sender, class_name: "User"
belongs_to :receiver, class_name: "User"
end
Run Code Online (Sandbox Code Playgroud)
one:
book: one
sender: jim
receiver: sarah
two:
book: two
sender: …Run Code Online (Sandbox Code Playgroud) 我有一个名为的文件frontend_configuration.rb,如下所示:
class FrontEndConfiguration
class << self
attr_accessor :base_url
end
end
Run Code Online (Sandbox Code Playgroud)
在我的development配置中,我有一行:
FrontEndConfiguration.base_url = "http://localhost:4200"
Run Code Online (Sandbox Code Playgroud)
当我尝试运行我的 rails 服务器时,它给了我一个错误说:
uninitialized constant FrontEndConfiguration (NameError)
Run Code Online (Sandbox Code Playgroud)
我在这里关注这个 Stackoverflow 答案:Rails 3 / Setting Custom Environment Variables
为什么 Rails 没有检测到我的自定义初始值设定项?
我正在使用 Rails 5 API only 模式。
ios ×7
autolayout ×3
android ×2
swift ×2
apng ×1
autocomplete ×1
bash ×1
core-data ×1
dropshadow ×1
file-io ×1
fixtures ×1
html ×1
icloud ×1
imageview ×1
ios7 ×1
ios8 ×1
node.js ×1
objective-c ×1
overcoat ×1
unit-testing ×1
xcode ×1
xcode6 ×1