我想在另一个线程的主线程上执行一个选择器,但是选择器有多个参数,类似于:
-(void) doSomethingWith:(int) a b:(float)b c:(float)c d:(float)d e:(float)e {
//...
}
我怎样才能使用它performSelectorOnMainThread: withObject: waitUntilDone:?
编辑
我想解释一下为什么我需要这个.
我在主线程上使用UIImageViews,并在另一个线程上对它们进行计算.我使用了很多计算,所以如果我在主线程上创建所有内容,那么应用程序就会滞后.我知道UI元素只能在主线程上操作,这就是为什么我希望它以这种方式工作,所以主线程可以听到没有滞后的触摸事件.
我有两个视图,viewA和viewB.我在viewA的顶部加载viewB
[self.view addSubview: viewB.view];
Run Code Online (Sandbox Code Playgroud)
我不想删除viewB,但我不知道怎么做.我试过了
[self.view removeFromSuperview];
Run Code Online (Sandbox Code Playgroud)
但这不起作用.我怎样才能做到这一点?
我正在使用AVPlayer播放视频.它们的长度很短,2-5秒.它们以随机顺序播放.问题是,当改变视频,并且新视频开始播放时,设备会滞后很短的时间,但我不会变得流畅.有没有办法用AVPlayer预加载视频?
如何更新时间和距离间隔,或者以不同的间隔再次调用requestLocationUpdates?
我的代码:
LocationManager locationManager = (LocationManager) activityObject.getSystemService(Context.LOCATION_SERVICE);
cll = new CheckinLocationListener();
LocationProvider gps = locationManager.getProvider(LocationManager.GPS_PROVIDER);
// GPS
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, timeDelay, distanceDelay, cll);
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
Run Code Online (Sandbox Code Playgroud)
onLocationChanged:
if(location.getSpeed()>=0 && location.getSpeed()<= 3)
{
LocationsModel.this.distanceDelay = 25;
LocationsModel.this.timeDelay = 10000;
}
else if(location.getSpeed()>=3 && location.getSpeed()<= 17)
{
LocationsModel.this.distanceDelay = 150;
LocationsModel.this.timeDelay = 60000;
}
else if(location.getSpeed()>=17)
{
LocationsModel.this.distanceDelay = 300;
LocationsModel.this.timeDelay = 240000;
}
Run Code Online (Sandbox Code Playgroud)
我想在下一个措施中使用新的时间间隔.
我的数据如下所示:
{
"name":"dan",
"somestring":"asdf",
"friends":[
{
"name": "carl",
"height":180,
...
},
{
"name": "john",
"height":165,
...
},
{
"name": "jim",
"height":170,
...
}
]
},
...
Run Code Online (Sandbox Code Playgroud)
我想检索朋友按高度降序排序的文档。
我试过了,db.getCollection('users').find({"name" : "dan"}, {"friends" : 1}).sort({"friends.height" : -1})但朋友列表保持不变。
编辑:我搞砸了我的数据结构,我修复了数组看起来像一个数组......