小编Dan*_*thy的帖子

通过对具有匹配id号的对象进行分组来重建NSArray?

我有一个NSArray,数组中的每个对象都有一个groupId和一个名字.每个对象都是唯一的,但有许多具有相同的groupId.有没有办法可以将阵列拆开并重建它,以便将名称分组为具有相应groubId的单个对象?这是数组目前的样子:

2013-03-12 20:50:05.572 appName[4102:702] the  array:  (
        {
        groupId = 1;
        name = "Dan";
    },
        {
        groupId = 1;
        name = "Matt";
    },
        {
        groupId = 2;
        name = "Steve";
    },
        {
        groupId = 2;
        name = "Mike";
    },
        {
        groupId = 3;
        name = "John";

    },
        {
        groupId = 4;
        name = "Kevin";
    }
)
Run Code Online (Sandbox Code Playgroud)

这就是我希望它看起来像:

2013-03-12 20:50:05.572 appName[4102:702] the  array:  (
        {
        groupId = 1;
        name1 = "Dan";
        name2 = "Matt";
    },
        {
        groupId = 2;
        name1 = …
Run Code Online (Sandbox Code Playgroud)

objective-c nsmutablearray nsarray ios

14
推荐指数
1
解决办法
1万
查看次数

在iOS中使用AVFoundation暂停和恢复同一文件的视频捕获

我试图找出如何实现在单个会话中重复暂停和恢复视频捕获的功能,但是将每个新段(每次暂停后捕获的段)添加到同一视频文件中,使用AVFoundation.目前,每当我再次按"停止"然后再"录制"时,它只会将新的视频文件保存到我的iphone专辑中,并开始捕获到单独的/新文件.我需要能够一遍又一遍地按下"录制/停止"按钮...仅在录制有效时捕获视频和音频...然后当按下"完成"按钮时,有一个包含所有的AV文件细分在一起.所有这些都需要在同一个捕获会话/预览会话中发生.

我能想到尝试这个的唯一方法是按下"完成"按钮,取出每个单独的输出文件并将它们组合成一个单独的文件......但我很确定处理时间基本上是粘贴一堆单独的剪辑在一起是不可接受的.而且,似乎这将是一个非常混乱和不必要的方式来解决这个问题,代码太多了.

有没有简单的方法可以在一个会话中暂停视频捕获,只需将捕获恢复到同一个文件?还是其他任何想法?

如果不是太麻烦,示例代码可以帮助我减轻...我仍然在学习和自学,所以我在解释中遵循术语和术语并不是很好.谢谢

编辑:这是我开始学习AVFoundation的项目...所以这是我想要改变以实现上述功能的代码:http: //developer.apple.com/library/ios/#samplecode/AVCam /Introduction/Intro.html

iphone video-capture objective-c avfoundation ios

8
推荐指数
1
解决办法
1万
查看次数

iOS 6 UIInterfacePortrait ONLY视图控制器被呈现并卡在横向中...当从导航堆栈中的横向视图控制器返回时

就像许多其他人一样,我遇到的问题是只有一个或两个viewcontrollers支持纵向和横向界面方向,在另一个肖像应用程序中.在iOS 6之前一切正常,但突然自动停止工作.感谢这里的一些很好的问题,我能够通过让初始的navController通过以下方式返回个人topViewController对shouldAutorotate的首选项来解决这个问题:

    - (BOOL)shouldAutorotate
{
    return  self.topViewController.shouldAutorotate;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}
Run Code Online (Sandbox Code Playgroud)

但是,我偶然发现了一个新问题.根vc(viewController A)不应该自动旋转,只应支持肖像.导航堆栈中的ViewController B支持纵向和横向.如果我在viewController B中,并且处于横向状态,并触摸"返回"以将视图弹回到viewController A ... vc A加载在横向中,它不应该支持,并且不会旋转回肖像,因为shouldAutorotate for vc A设置为NO ...

任何关于如何处理这个问题的想法将不胜感激.我最初的想法是使用手动方法覆盖vc B的"后退"按钮,如果视图处于横向状态,则首先强制旋转回纵向...然后将视图控制器弹回到vc A ......但我无法弄清楚如何以编程方式强制旋转.有任何想法吗?

这是vc A中的接口方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return NO;
}

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}
Run Code Online (Sandbox Code Playgroud)

这是他们在vc B中的内容:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

-(BOOL)shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}
Run Code Online (Sandbox Code Playgroud)

xcode objective-c uiinterfaceorientation autorotate ios6

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

使用Graph API或FQL将所有照片都包含在一个Facebook Feed帖子中?

我正在使用Facebook图形API来获取我最近的帖子并使用"graph.facebook.com/me/feed"提供项目.我遇到的问题是当一个Feed对象是一张包含多张照片的帖子时,结果中的数据只包含其中一张照片的信息,我似乎无法找到一种方法来将其他照片包含在帖子中.

来自Feed对象的一些细节:

"type": "photo" 
"status_type": "mobile_status_update"
"picture": "http://the_url_to_the_one_photo_it_does_return.jpg" 
"message": "The message/note attached with the photos for the post",
"id": "xxxxxxxx_xxxxxxxxxx" 
"object_id": "yyyyyyyyyyyyy"
Run Code Online (Sandbox Code Playgroud)

我尝试通过请求(graph.facebook.com/xxxxxx_xxxxxxxxxxx)发送"id"(帖子ID),希望它能给我详细介绍帖子中包含的所有照片,但事实并非如此.也尝试使用"object_id",但看起来这只是与单个包含的照片对象相对应的id.

我整天都在研究FQL.这对我来说还是新的,但我似乎已经掌握了基础知识,似乎有任何希望找到这个,它会以某种方式通过FQL查询从帖子中传递"id".

有没有人知道如何获取多张照片Feed帖子中包含的所有照片的详细信息?如果这是唯一的方法,我可以使用图形或fql进行肮脏的解决方法.谢谢!顺便说一句,我在iOS/Objective-C工作.

facebook facebook-fql facebook-graph-api ios

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

cornerRadius上的CGAffineTransformMakeScale动画舍入了UIButton

我正在舍入一个UIBUtton,这很好(自我是一个uibutton子类):

self.layer.cornerRadius = self.frame.size.width/2;
self.layer.masksToBounds = YES;
self.clipsToBounds = YES;
Run Code Online (Sandbox Code Playgroud)

但我也试图动画按钮缩小比例然后返回到原始大小,如下所示:

[UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
    self.layer.affineTransform = CGAffineTransformMakeScale(0.0f, 0.0f);
} completion:^(BOOL finished) {
    [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.layer.affineTransform = CGAffineTransformMakeScale(1.0f, 1.0f);
    } completion:nil];
}];
Run Code Online (Sandbox Code Playgroud)

收缩/恢复动画应该发生.然而,之后我失去了角落半径,按钮又回到了正方形.如何在保持圆形按钮的同时动画和更改变换比例?

我也试过以下.它会在动画结束时将按钮恢复为圆形状态,但是在动画开始时它会回到正方形并且它看起来非常糟糕:

[UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
    self.layer.affineTransform = CGAffineTransformMakeScale(0.0f, 0.0f);
    self.layer.cornerRadius = 0.0f;
    self.layer.masksToBounds = YES;
    self.clipsToBounds = YES;
} completion:^(BOOL finished) {
    [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.layer.affineTransform = CGAffineTransformMakeScale(1.0f, 1.0f);
        self.layer.cornerRadius = self.frame.size.width/2;
        self.layer.masksToBounds = YES;
        self.clipsToBounds = YES;
    } completion:nil]; …
Run Code Online (Sandbox Code Playgroud)

uibutton calayer ios cgaffinetransformscale ios7

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