我正在尝试实现一个操作队列,我有以下场景:
NSOperation A
NSOperation B
NSOperation C
NSOperation D
NSOperationQueue queue
Run Code Online (Sandbox Code Playgroud)
我开始加入A到queue.
在执行期间,A我需要从中获取一些数据B,我无法继续,A直到B返回我需要的内容.
B取决于C和C取决于相同的情况将发生D.
为了管理这个,每个NSOperation我都有这个代码:
NSOperation *operation; //This can be A, B, C, D or any other NSOperation
[self setQueuePriority:NSOperationQueuePriorityVeryLow]; //Set the current NSOperation with low priority
[queue addOperation: operation]; //Add the operation that I want to the queue
while(!operation.isFinished && !self.isCancelled){} //I need to wait the operation that …Run Code Online (Sandbox Code Playgroud) 我正在尝试实现一个粘贴处理程序来从用户的剪贴板中获取图像.我希望这只能在Google Chrome上运行,我并不担心其他浏览器.
这是我在互联网上找到的一种方法的一部分,我正在努力调整它.
// Get the items from the clipboard
var items = e.clipboardData.items;
if (items) {
// Loop through all items, looking for any kind of image
for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf("image") !== -1) {
// We need to represent the image as a file,
var blob = items[i].getAsFile();
// and use a URL or webkitURL (whichever is available to the browser)
// to create a temporary URL to the object
var …Run Code Online (Sandbox Code Playgroud) 我需要做以下任务:
1)从sqlite数据库中读取一些数据
2)处理数据
3)用处理过的数据生成一些图表
如果我有一个用户在应用程序中输入了许多数据,那么有一天这个分析可能会变慢并冻结UI.
那么,处理它的正确方法是什么,允许用户与UI交互,可以选择取消操作还是退出屏幕?
我需要为我的所有任务创建简单的线程,并使用取消事件或标志来停止每个任务?或者还有另一种方法吗?
例如:
任务1:在带有标志的线程中从sqlite读取数据,以便在需要时停止进程.
任务2:使用标志处理带有标志的线程中的数据,以便在需要时停止进程.
任务3:将数据传递给第三方组件.此时,它可以取消正在其他组件上运行的操作吗?
我是在思考正确的方法,还是可以改进某些方面?
我对Jquery中的.click函数有疑问.我有这个代码:
for (var i = 0; i < 5; i++) {
var divTest = $('<div></div>');
divTest.text("My Div " + i);
divTest.click(function() {
alert("Alert: Div " + i);
});
$('#myTest').append(divTest);
}?
Run Code Online (Sandbox Code Playgroud)
我希望在"myTest"元素中添加5个div,对于每个div,onclick函数会显示带有相应div编号的警报.
正确添加了div,但是当我点击div时,我总是得到带有文本的警报:"Alert: Div 5".为什么?我需要改变什么才能产生我期待的行为?
这是我的jsFiddle:http://jsfiddle.net/BKFGm/2/
我有一个引用System.Data.SQLite(来自nuget)的C#类库.这是构建后我的bin文件夹的结构:
- MyProject.dll
- System.Data.SQLite.dll
- 86/SQLite.Interop.dll
- X64/SQLite.Interop.dll
System.Data.SQLite需要SQLite.Interop运行并在运行时找到正确的dll.但是,当我使用包含项目主输出的InstallShield生成安装程序时,不会复制x86和x64文件夹,并且我的应用程序无法运行.
有什么方法可以强制Visual Studio在主输出中包含x86和x64文件夹?
有没有办法在InstallShield中手动包含文件夹和相对路径?
我的环境:
- Visual Studio 2012专业版
- 安装Shield 2013限量版(免费)
- System.Data.SQLite 1.0.96
dll installshield system.data.sqlite visual-studio-2012 installshield-le
我遇到了问题NSDateFormatter.它将返回null某些特定日期.
我做了这个函数来调试案例:
- (void) debugTest:(NSString *)dateStr{
NSLog(@"String: %@", dateStr);
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd"];
NSDate *dateObj = [df dateFromString: dateStr];
NSLog(@"Date: %@", dateObj);
}
Run Code Online (Sandbox Code Playgroud)
这是某些日期的日志输出:
String: 2012-10-18
Date: 2012-10-18 03:00:00 +0000
String: 2012-10-19
Date: 2012-10-19 03:00:00 +0000
String: 2012-10-20
Date: 2012-10-20 03:00:00 +0000
String: 2012-10-21
Date: (null)
String: 2012-10-22
Date: 2012-10-22 02:00:00 +0000
String: 2012-10-23
Date: 2012-10-23 02:00:00 +0000
Run Code Online (Sandbox Code Playgroud)
为什么它仅为日期返回null 2012-10-21?
我做了其他测试,间隔时间2011-10-01 to 2014-11-01和返回的日期null:
2011-10-16, 2012-10-21, 2013-10-20, 2014-10-19 …Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的场景,对我不起作用.我有一个带两个视图控制器的故事板:
ViewController1
- ViewA
- ViewB
ViewController2
- ViewC
Run Code Online (Sandbox Code Playgroud)
我ViewController1正在按预期工作,当我旋转设备时,视图会根据我定义的自动布局正确调整.
我ViewController2的自由格式大小(768x722),我取消选中"从笔尖调整视图大小"选项.
这是我的 ViewController1 didLoad
- (void)viewDidLoad
{
[super viewDidLoad];
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc2 = [story instantiateViewControllerWithIdentifier:@"vc2"];
[self addChildViewController:vc2];
[vc2 didMoveToParentViewController:self];
[self.viewA addSubview:vc2.view];
}
Run Code Online (Sandbox Code Playgroud)
当我- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation从ViewControlled2被调用的方法旋转设备时,它显示正确的方向.但是,ViewC不会自行调整大小,也不会遵循我的自动布局设置.
有谁知道我怎么解决?我只是想添加我的ViewController2内部ViewA并保持自动布局工作的视图ViewController2.我只需要iOS 7的解决方案,因此不需要与早期版本兼容.
有人可以帮帮我吗?
我在代码的这一部分有一些随机崩溃:
-(void) goBack {
[self performSelectorInBackground:@selector(addActivityIndicator) withObject:nil];
[self.navigationController popViewControllerAnimated:YES];
}
- (void)addActivityIndicator {
@autoreleasepool {
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithCustomView:activityView];
[activityView startAnimating];
self.navigationItem.leftBarButtonItem = barButton;
}
}
Run Code Online (Sandbox Code Playgroud)
当我想退出存在这些方法的屏幕时,另一个ViewController必须处理一些数据.为了通知用户正在进行处理,我在导航栏的左侧按钮中添加了一个活动指示器.
问题是有时候我会得到一个exc_bad_accessin addActivityIndicator方法.频率非常随机,有时XCode @autoreleasepool会在结束时显示错误,有时候会显示错误self.navigationItem.leftBarButtonItem = barButton;
我想有时我的viewController被销毁但是线程仍在运行并尝试访问不再存在的对象的navigationItem.但我不确定这是不是问题,我不知道如何解决它.
我在我的项目中使用ARC,这个问题出现在我测试的所有iOS版本中.
拜托,任何人都可以向我解释发生了什么,我该如何解决这个问题?
谢谢.
ios ×5
objective-c ×4
javascript ×2
nsthread ×2
autolayout ×1
base64 ×1
blob ×1
date-format ×1
dll ×1
dom ×1
freeze ×1
image ×1
jquery ×1
nsoperation ×1
null ×1
onclick ×1
orientation ×1