小编Asm*_*ita的帖子

如何在ios中水平地将四个图像从一个位置移动到另一个位置

我有一个查询.我正在尝试开发像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)

iphone objective-c ios

6
推荐指数
1
解决办法
308
查看次数

如果在ios8中使用搜索栏找不到结果,如何隐藏节标题

如果名称存在,那么它将如下所示

如果名称不存在,那么它看起来像这样我想隐藏部分标题,如果名称不存在

-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
    if (_segment.selectedSegmentIndex==0)
    {
        return sortedKeys;
    }
    else
    {
       return sortedKeys1;
    }
}
Run Code Online (Sandbox Code Playgroud)

我使用这段代码,但如果名称不存在,我不想要章节标题,现在它给我所有章节标题

iphone objective-c ios searchbar

5
推荐指数
1
解决办法
110
查看次数

在 iOS 中播放 m3u8 文件

我知道这个问题问了很多次但没有得到正确的解决方案,

我有一个 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 ' 视频正在播放什么任何人都可以帮助我的问题。

ios avplayer swift

5
推荐指数
1
解决办法
5844
查看次数

如何在“小部件/今日扩展”上打开特定视图控制器,请单击

我正在尝试在小部件click上打开特定的视图控制器,但无法打开它,我能够使用url模式打开应用程序,但是我想打开特定的视图控制器我该怎么做,这是使用open app的代码网址架构:

@IBAction func open_app(_ sender: Any) { extensionContext?.open(URL(string: "open://")! , completionHandler: nil) } 在按钮上单击,我正在使用url模式成功运行应用程序。但是现在我想在该点击上打开特定的视图控制器,我该怎么做?

widget today-extension swift3

4
推荐指数
1
解决办法
1689
查看次数

sendSynchronousRequest:urlrequest returningResponse:&responce error:&WatchOS2中的错误无法使用

我想从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)

api objective-c ios watchkit

3
推荐指数
1
解决办法
619
查看次数