我想func adjustmentBestSongBpmHeartRate() 每1.1秒调用一次方法.我用过Timer,但它不起作用.我已阅读该文档并发现了大量示例代码,它仍然可以正常工作!我错过了什么吗?
timer = Timer.scheduledTimer(timeInterval: 1.1, target: self, selector: #selector(self.adjustmentBestSongBpmHeartRate), userInfo: nil, repeats: false)
timer.fire()
func adjustmentBestSongBpmHeartRate() {
print("frr")
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试根据用户的偏好设置UITextView的光标颜色.他们用按钮选择他们想要的颜色.
默认情况下,textview的光标颜色为白色.当用户按下按钮时,它可能会变为绿色:
[_textView setTintColor:[UIColor greenColor]];
[_textView setTextColor:[UIColor greenColor]];
Run Code Online (Sandbox Code Playgroud)
我确信这个方法调用是有效的,因为textview的文本改变颜色,而不是光标...
我试图UITableViewController动态定制 .所以我改变了许多属性cell.textLabel.现在我想将这些属性复制detailTextLabel到我通过代码创建的一个标签.怎么做?
cell.textLabel.backgroundColor = [UIColor colorWithRed:0 green:0.188235 blue:0.313725 alpha:1];
cell.textLabel.textColor=[UIColor whiteColor];
cell.textLabel.font=[UIFont fontWithName:@"HelveticaNeue" size:26];
cell.textLabel.autoresizingMask=UIViewAutoresizingFlexibleRightMargin;
Run Code Online (Sandbox Code Playgroud)
这是我的cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
cell.textLabel.text=[_names objectAtIndex:indexPath.row];
cell.textLabel.tag=indexPath.row;
cell.detailTextLabel.text=[_phones objectAtIndex:indexPath.row];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow.png"] ];
[imageView setFrame:CGRectMake(380,10,30,50)];
[cell addSubview:imageView];
//customize the seperator
UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1000, 1)];/// change size as you need.
separatorLineView.backgroundColor = [UIColor grayColor];// you can also put image here …Run Code Online (Sandbox Code Playgroud) 我想支持VoiceOver.我有一个UIButton内心UITableViewCell.根据最佳实践,我已禁用了accessibility(.isAccessibilityElement = false)按钮,并为cell(accessibilityCustomActions, NSAccessibilityCustomAction)实现了自定义辅助功能.
这样VoiceOver就不会找到并读取按钮作为自己的元素.为了使按钮后面的功能可访问,我已向单元格添加了自定义辅助功能操作.通过自定义操作,用户可以通过向上和向下滑动来选择操作.然后用双击执行它.
现在我想用UITest测试这个动作.无法访问UITest内的按钮,因为它已禁用可访问性.
如何在UITest内执行自定义辅助功能?
要求 -我正在构建一个超本地应用程序,它将根据用户的位置为用户提供服务.在应用程序中我可以获得他当前的位置并相应地显示优惠,但我现在需要的是根据他的位置向用户发送推送通知.所以我想找出用户的位置并根据他的位置发送优惠.
我已经阅读了有关重大变更位置服务的 Apple文档,但后来这个答案说,一旦应用程序被杀,它将无法运行.
我还阅读了有关跟踪用户位置的信息,但这对我来说无效.我在后台没有获得超过5个更新.
我目前的代码viewDidLoad-
if (self.locationManager == nil)
{
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.delegate = self;
self.locationManager.allowsBackgroundLocationUpdates = true;
self.locationManager.pausesLocationUpdatesAutomatically = false;
if ([CLLocationManager authorizationStatus] != AVAuthorizationStatusAuthorized) {
[self.locationManager requestAlwaysAuthorization];
}
}
[self.locationManager startUpdatingLocation];
Run Code Online (Sandbox Code Playgroud)
我的委托方法看起来像这样 -
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
if (UIApplication.sharedApplication.applicationState == UIApplicationStateActive) {
// Get updated data according to location
} else {
// Send location to server
}
}
Run Code Online (Sandbox Code Playgroud)
请建议一些适当的方式,我可以生活在1公里左右的精度. …
我正在制作一个应用程序,它使用GCM,后台任务和钥匙串来保存用户的信息.我通过将设备UDID添加到Apple开发者帐户,使用我的开发认证发布了一个版本.但几天之后,我得到了用户的反馈,每当启动时都会崩溃.我查看代码但找不到这些bug.我有这个日志:
Nov 23 16:34:51 iPhone securityd[9174] <Error>: secTaskDiagnoseEntitlements MISSING keychain entitlements: no stored taskRef found
Nov 23 16:34:51 iPhone securityd[9174] <Error>: secTaskDiagnoseEntitlements MISSING keychain entitlements: no stored taskRef found
Nov 23 16:34:51 iPhone amfid[10315] <Error>: SecTrustEvaluate [leaf IssuerCommonName SubjectCommonName]
Nov 23 16:34:51 iPhone securityd[9174] <Error>: secTaskDiagnoseEntitlements MISSING keychain entitlements: no stored taskRef found
Nov 23 16:34:51 iPhone securityd[9174] <Error>: secTaskDiagnoseEntitlements MISSING keychain entitlements: no stored taskRef found
Nov 23 16:34:51 iPhone amfid[10315] <Error>: SecTrustEvaluate [leaf Revocation1]
Nov 23 16:34:51 iPhone …Run Code Online (Sandbox Code Playgroud) 我在谷歌地图中用标记绘制了路径.所以路径是静态的,但标记需要改变它们的位置.如何在不使用的情况下删除所有标记mapview.clear(),因为它也会从地图中清除我的路径.
有解决方案吗
我正在使用这个库进行GPUImage处理.
我试图像在iOS GPUImage库中那样并行运行过滤器,但是在向一个扩展的过滤器添加3个输入时遇到问题MultiInputFilter.我想要结合起来
BasicCameraInputFilterCannyEdgeDetectionFilterSobelEdgeDetectionFilterBasicCameraInputFilter直接相机输入在哪里.
BasicCameraInputFilter cameraInput = new BasicCameraInputFilter();
CannyEdgeDetectionFilter cannyEdgeDetectionFilter = new CannyEdgeDetectionFilter(1.0f,0.3f,0.6f);
SobelEdgeDetectionFilter sobelEdgeDetectionFilter = new SobelEdgeDetectionFilter();
CombinationFilter combinationFilter = new CombinationFilter();
cameraInput.addTarget(combinationFilter);
cannyEdgeDetectionFilter.addTarget(combinationFilter);
sobelEdgeDetectionFilter.addTarget(combinationFilter);
combinationFilter.registerFilterLocation(cameraInput,0);
combinationFilter.registerFilterLocation(cannyEdgeDetectionFilter,1);
combinationFilter.registerFilterLocation(sobelEdgeDetectionFilter,2);
combinationFilter.addTarget(this);
registerInitialFilter(cameraInput);
registerFilter(cannyEdgeDetectionFilter);
registerFilter(sobelEdgeDetectionFilter);
registerTerminalFilter(combinationFilter);
Run Code Online (Sandbox Code Playgroud)
这是我的片段着色器 CombinationFilter
"precision mediump float;\n"
+"uniform sampler2D " + UNIFORM_TEXTURE0 + ";\n"
+"uniform sampler2D " + UNIFORM_TEXTUREBASE + 1 + ";\n"
+"uniform sampler2D " + UNIFORM_TEXTUREBASE + 2 + ";\n"
+"varying vec2 " + VARYING_TEXCOORD …Run Code Online (Sandbox Code Playgroud) 我正在尝试更改应用程序进入后台时由iOS自动捕获的屏幕截图.
但是我不确定这个屏幕截图的确切时间.
例如:
如果您在应用程序中下拉通知栏,则会调用以下方法:
- (void) applicationWillResignActive:(UIApplication *) application {
}
Run Code Online (Sandbox Code Playgroud)
此外,如果您在应用程序中双击主页按钮,则会调用相同的方法.此外,如果显示警报视图,则调用"applicationWillResignActive".
但在这两种情况下
- (void) applicationDidEnterBackground:(UIApplication *) application {
}
Run Code Online (Sandbox Code Playgroud)
不叫.
所以我的问题是,即使应用程序没有进入后台,是否在调用applicationWillResignActive后捕获了截图?或者iOS仅在applicationDidEnterBackground之后捕获屏幕截图?
我正在尝试使用CoreData,但是当我将它添加到我的项目中时,我只获得了两个新方法:
- (NSPersistentContainer *)persistentContainer
Run Code Online (Sandbox Code Playgroud)
和
- (void)saveContext
Run Code Online (Sandbox Code Playgroud)
现在我无法使用旧的方法CoreData,我找不到任何有这些新方法和Objective-C的教程.如何CoreData使用persistentContainerObjective-c在Xcode 8中保存和获取数据?
ios ×8
swift ×7
objective-c ×5
android ×1
core-data ×1
gmsmapview ×1
google-maps ×1
gpuimage ×1
iphone ×1
marker ×1
shader ×1
swift3 ×1
timer ×1
uitextview ×1
voiceover ×1
xcode ×1
xcode8 ×1
xcuitest ×1