使用iOS 10的Apple已弃用openURL:for openURL:option:completionHandler如果我有:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.google.com"]];
Run Code Online (Sandbox Code Playgroud)
它将如何变成?选项:<#(nonnull NSDictionary*)#>详细说明
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.google.com"] options:<#(nonnull NSDictionary<NSString *,id> *)#> completionHandler:nil];
Run Code Online (Sandbox Code Playgroud)
谢谢
更新选项:@ {}对于没有键和值的空字典 http://useyourloaf.com/blog/querying-url-schemes-with-canopenurl/
我是初学者,也许这是一个微不足道的问题.我有这个方法:
-(NSString *)getInfoFormediaItem:(MPMediaItemCollection *)list {
NSString *trackCount;
if ([list count] > 0) {
trackCount = [NSString stringWithFormat:NSLocalizedString(@"%lu Songs", @""), (unsigned long)[list count]];
} else if([list count] == 1) {
trackCount = [NSString stringWithFormat:NSLocalizedString(@"1 Song", @"")];
} else {
trackCount = [NSString stringWithFormat:NSLocalizedString(@"0 Song", @"") ];
}
return [NSString stringWithFormat:@"%@", trackCount];
}
Run Code Online (Sandbox Code Playgroud)
我想在这里用MPMediaItemCollection调用它:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if( cell == nil )
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
}
MPMediaQuery …Run Code Online (Sandbox Code Playgroud) 我对Objective-C的经验不多.我试图在用户按下按钮后结束动画.在viewDidLoad我添加了这个:
UILongPressGestureRecognizer *recoginzer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onPress:)];
[_buttonStart addGestureRecognizer:recoginzer];
Run Code Online (Sandbox Code Playgroud)
然后在我用来setCompletionBlock确定动画何时结束的方法中,但它不起作用.
-(void)onPress:(UILongPressGestureRecognizer*)longpress {
if (longpress.state == UIGestureRecognizerStateBegan) {
circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(2, 2, _buttonStart.frame.size.width-4, _buttonStart.frame.size.height-4) cornerRadius:(_buttonStart.frame.size.width/2)-8].CGPath;
circle.fillColor = [UIColor clearColor].CGColor;
circle.strokeColor = [UIColor whiteColor].CGColor;
circle.lineWidth = 2.5;
[_buttonStart.layer addSublayer:circle];
[CATransaction begin];
CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
drawAnimation.duration = 3.0;
drawAnimation.repeatCount = 1.0;
drawAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
drawAnimation.toValue = [NSNumber numberWithFloat:1.0f];
drawAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[circle addAnimation:drawAnimation forKey:@"drawCircleAnimation"];
[CATransaction setCompletionBlock:^{
NSLog(@"DONE");
}];
[CATransaction commit];
} else if …Run Code Online (Sandbox Code Playgroud)