我有一个查询.我正在尝试开发像iOS中的Abacus这样的游戏.我想在iOS中水平地将四个图像从一个位置移动到另一个位置.任何人都可以帮助我,请问我在iOS中如何做到这一点.我参考这个链接如何使用动画在iphone应用程序中将对象从一个地方移动到另一个地方 但是使用这个我能够水平移动一个图像我想移动四个图像我是如何做到这一点的.
这是我尝试过的:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
CGPoint loc = [touch locationInView:self.view];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
CGRect rect = CGRectMake(loc.x, _img.frame.origin.y, _img.frame.size.height, _img.frame.size.width);
[_img setFrame:rect];
[UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud) 
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
if (_segment.selectedSegmentIndex==0)
{
return sortedKeys;
}
else
{
return sortedKeys1;
}
}
Run Code Online (Sandbox Code Playgroud)
我使用这段代码,但如果名称不存在,我不想要章节标题,现在它给我所有章节标题
我知道这个问题问了很多次但没有得到正确的解决方案,
我有一个 m3u8 文件无法在 AVPlayer 中工作,但是如果我使用互联网上已有的其他 m3u8 文件,并且可以与 AVPlayer 正常工作,这是我的代码
func playVideo() {
let videoURL = URL(string: "https://architectsummit.s3.us-east-2.amazonaws.com/hls/playlist-with-vtt.m3u8")
let player = AVPlayer(url: videoURL!)
var playerViewController = AVPlayerViewController()
playerViewController.player = player
DispatchQueue.main.async {
self.present(playerViewController, animated: true) {
playerViewController.player!.play()
}
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我使用了我们的开发人员提供的 m3u8 文件,但是如果我在上面的代码中使用这个 url ' https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8 ' 视频正在播放什么任何人都可以帮助我的问题。
我正在尝试在小部件click上打开特定的视图控制器,但无法打开它,我能够使用url模式打开应用程序,但是我想打开特定的视图控制器我该怎么做,这是使用open app的代码网址架构:
@IBAction func open_app(_ sender: Any)
{ extensionContext?.open(URL(string: "open://")! ,
completionHandler: nil)
}
在按钮上单击,我正在使用url模式成功运行应用程序。但是现在我想在该点击上打开特定的视图控制器,我该怎么做?
我想从WatchOS上的API获取我使用的数据,NSURLConnection但我得到的错误在WatchOS2中不可用,在这里我添加我使用的代码请看看并帮助我,谢谢
NSURLRequest *urlrequest =[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=2de143494c0b295cca9337e1e96b00e0"]];
NSURLResponse *responce = nil;
NSError *error = nil;
NSData* data = [NSURLConnection sendSynchronousRequest:urlrequest returningResponse:&responce error:&error];
NSMutableDictionary *allData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
NSString *currentWeather = nil;
NSArray* weather = allData[@"weather"];
for (NSDictionary *theWeather in weather)
{
currentWeather = theWeather[@"main"];
}
self.lbl.text = currentWeather;
Run Code Online (Sandbox Code Playgroud)