我正在尝试实现dropBox同步,需要比较两个文件的日期.一个在我的dropBox帐户上,一个在我的iPhone上.
我想出了以下内容,但我得到了意想不到的结果.我想在比较这两个日期时我做了一些根本错误的事情.我只是使用了> <运算符,但我想这并不好,因为我正在比较两个NSDate字符串.开始了:
NSLog(@"dB...lastModified: %@", dbObject.lastModifiedDate);
NSLog(@"iP...lastModified: %@", [self getDateOfLocalFile:@"NoteBook.txt"]);
if ([dbObject lastModifiedDate] < [self getDateOfLocalFile:@"NoteBook.txt"]) {
NSLog(@"...db is more up-to-date. Download in progress...");
[self DBdownload:@"NoteBook.txt"];
NSLog(@"Download complete.");
} else {
NSLog(@"...iP is more up-to-date. Upload in progress...");
[self DBupload:@"NoteBook.txt"];
NSLog(@"Upload complete.");
}
Run Code Online (Sandbox Code Playgroud)
这给了我以下(随机和错误)输出:
2011-05-11 14:20:54.413 NotePage[6918:207] dB...lastModified: 2011-05-11 13:18:25 +0000
2011-05-11 14:20:54.414 NotePage[6918:207] iP...lastModified: 2011-05-11 13:20:48 +0000
2011-05-11 14:20:54.415 NotePage[6918:207] ...db is more up-to-date.
Run Code Online (Sandbox Code Playgroud)
或者这个恰好是正确的:
2011-05-11 14:20:25.097 NotePage[6903:207] dB...lastModified: 2011-05-11 13:18:25 +0000
2011-05-11 14:20:25.098 NotePage[6903:207] iP...lastModified: 2011-05-11 13:19:45 +0000 …
Run Code Online (Sandbox Code Playgroud) 我的iPhone应用程序需要迁移其核心数据存储,而且一些数据库非常庞大.Apple的文档建议使用"多次传递"来迁移数据以减少内存使用.但是,文档非常有限,并没有很好地解释如何实际执行此操作.有人可以指出我一个好的例子,或者详细解释如何实际解决这个问题的过程吗?
是否可以根据活动配置控制将哪些文件复制到捆绑包中?我不想为此添加另一个目标,所以这不是一个选项.
现实生活中的例子是一个启动视频,实际上大小为8mb,很长.应用程序的每次启动都会显示此视频令人讨厌.我不想破解太多代码,因此解决方案是一个非常短的启动视频,这是在调试配置处于活动状态时复制到捆绑包的候选者.
是的,我可以使调试视频非常小,所以如果它与发布一起提供并不会受到影响,但为了学习新东西,我需要一种方法来控制根据配置复制哪个文件.我想一个Run Script会这样做,但也许有一个我看不到的简单解决方案.
提前致谢!
在iOS中,是否可以在UIWebView上放置点击识别器,以便当有人单击Web视图时,会执行某个操作?
当我点击我的webView时,下面的代码似乎没有火手柄.
谢谢.
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleTap)];
tap.numberOfTapsRequired = 1;
[webView addGestureRecognizer:tap];
[tap release];
-(void) handleTap {
NSLog(@"tap");
}
Run Code Online (Sandbox Code Playgroud) 我想在旋转后正确应用阴影.这是我的代码:
myButton.transform = CGAffineTransformMakeRotation(M_PI / 180.0 * 90.0);
myButton.layer.shadowOffset = CGSizeMake(12.0, 12.0);
myButton.layer.shadowRadius = 2.0;
myButton.layer.shadowOpacity = 0.8;
myButton.layer.shadowColor = [UIColor blackColor].CGColor;
Run Code Online (Sandbox Code Playgroud)
没有旋转,阴影看起来很好:
但是在将它旋转90°之后,阴影也会旋转:
如果没有覆盖drawRect方法并进行低级绘图,我能做些什么吗?或者也许某些方法用给定的旋转角度校正shadowOffset?手动校正90°的偏移很容易,所以这是不可取的;)
它应该如下所示:
提前致谢!
在Bartosz Ciechanowski的帮助下,这个现在有效了!
float angleInRadians = M_PI / 180.0 * -35.0;
myButton.transform = CGAffineTransformMakeRotation(angleInRadians);
myButton.layer.shadowOffset = [self correctedShadowOffsetForRotatedViewWithAngle:(angleInRadians)
andInitialShadowOffset:CGSizeMake(12.0, 12.0)];
myButton.layer.shadowRadius = 2.0;
myButton.layer.shadowOpacity = 0.8;
myButton.layer.shadowColor = [UIColor blackColor].CGColor;
Run Code Online (Sandbox Code Playgroud)
这导致:
代替
试图了解UIView和CALayer之间的关系.我阅读了Apple文档,但没有详细描述两者之间的关系.
为什么当我添加背景图像来查看"customViewController.view"时,我得到图像的不需要的黑色.
当我将背景图像添加到图层"customViewController.view.layer"时,图像的黑色区域消失了(这就是我想要的),但背景图像是颠倒翻转的.这是为什么?
如果我要添加标签/视图/按钮/等.对于视图,图层的背景图像是否会阻止它们,因为CAlayer由UIView支持?
当您设置UIView的背景颜色时,它会自动设置关联图层的背景颜色吗?
- (void)viewDidLoad
{
[super viewDidLoad];
customViewController = [[CustomViewController alloc] init];
customViewController.view.frame = CGRectMake(213, 300, 355, 315);
customViewController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"login_background.png"]];
// customViewController.view.layer.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"login_background.png"]].CGColor;
[self.view addSubview:customViewController.view];
}
Run Code Online (Sandbox Code Playgroud)视图中的背景图片:
- (void)viewDidLoad
{
[super viewDidLoad];
customViewController = [[CustomViewController alloc] init];
customViewController.view.frame = CGRectMake(213, 300, 355, 315);
// customViewController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"login_background.png"]];
customViewController.view.layer.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"login_background.png"]].CGColor;
[self.view addSubview:customViewController.view];
}
Run Code Online (Sandbox Code Playgroud)
在view.layer中的背景图像:
CTCarrier的carrierName的文档说明"如果用户正在漫游,则值不会改变;它始终代表用户拥有帐户的提供商."
然而,它并没有对mobileNetworkCode说同样的话.这是基于当前运营商的变化还是保持不变?
我正在尝试查找手机是否在startMonitoringSignificantLocationChanges回调中漫游,以便避免地理定位.
我正在阅读有关内存管理的所有文档,我对某些事情感到有些困惑.
使用@property时,它会为对象创建getter/setter:
.h:@property(retain,nonatomic)NSString*myString
.m:@synthesize myString
我理解这一点,但我感到困惑的是使用自我.我在不同的博客和书籍中看到了不同的语法.我见过:
myString = [NSString alloc] initWithString:@"Hi there"];
Run Code Online (Sandbox Code Playgroud)
要么
self.myString = [NSString alloc] initWithString:@"Hi there"];
Run Code Online (Sandbox Code Playgroud)
然后在dealloc我看到:
self.myString = nil;
Run Code Online (Sandbox Code Playgroud)
要么
[myString release];
Run Code Online (Sandbox Code Playgroud)
要么
self.myString = nil;
[myString release];
Run Code Online (Sandbox Code Playgroud)
在这个网站上,有人说使用self会为保留计数增加另一个增量?是真的,我没有在任何地方见过.
提供自动释放的自动吸气剂/定型器吗?
这是完成所有这些的正确方法吗?
谢谢!
请原谅这里的新手 - 我在模拟器中运行一个应用程序,有时当它崩溃时它会在控制台中发布有用的信息,其他时候绝对没有.当它什么都没发布时,开始追踪崩溃原因的步骤是什么?
ios ×8
iphone ×7
objective-c ×6
uiview ×2
xcode ×2
bundle ×1
calayer ×1
cocoa-touch ×1
core-data ×1
debugging ×1
gdb ×1
nsdate ×1
properties ×1
roaming ×1
shadow ×1
stack-trace ×1
synthesizer ×1
uikit ×1
uiwebview ×1
webdav ×1