Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从集合视图中的按钮发送操作_Ios_Button_Uicollectionview_Pushviewcontroller - Fatal编程技术网

Ios 从集合视图中的按钮发送操作

Ios 从集合视图中的按钮发送操作,ios,button,uicollectionview,pushviewcontroller,Ios,Button,Uicollectionview,Pushviewcontroller,我有一个查询,它提取10个最近的对象,并在集合视图的按钮中显示每个对象的标题。我试图做的是让一个操作打开一个新的视图控制器,显示从集合视图中选择的对象的信息。我需要的帮助是在按钮操作中连接所选对象。我是Xcode新手,需要一些建议。这是定义查询的代码: int i = 0; for (PFObject *object in objects) { if (i >= [self.EventTitles count]) break;//to make su

我有一个查询,它提取10个最近的对象,并在集合视图的按钮中显示每个对象的标题。我试图做的是让一个操作打开一个新的视图控制器,显示从集合视图中选择的对象的信息。我需要的帮助是在按钮操作中连接所选对象。我是Xcode新手,需要一些建议。这是定义查询的代码:

int i = 0;
        for (PFObject *object in objects) {
            if (i >= [self.EventTitles count]) break;//to make sure we only write up to the max number of UILabels available in EventTitles
            [(UIButton *)self.EventButtons[i] setTitle:[object objectForKey:@"name"] forState:UIControlStateNormal];
            [(UIButton *)self.EventButtons[i] addTarget:self action:(social:) forControlEvents:UIControlEventTouchUpInside];
            i++;
                        }
然后是动作代码

- (IBAction)social:(id)sender{

    UIActionSheet *share = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Close" destructiveButtonTitle:nil otherButtonTitles:@"Call",@"Directions",@"Website",@"Checkin", nil];

    [share showInView:self.view];
}


- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

    //Each button title we gave to our action sheet is given a tag starting with 0.
    if (buttonIndex == 0) {
        NSString* yourActualNumber = [NSString stringWithFormat:@"tel:%@",????????];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:yourActualNumber]];
        NSLog(@"phone");
        //Check Twitter accessibility and at least one account is setup.

    }
我只是不知道如何将对象连接到动作,然后在新的视图控制器上显示该信息


更新:我用查询中的新行更新了代码,但是它无法说明社交活动是未声明的,不管它是什么?我还更改了操作以执行操作表,而不是新的视图控制器。我现在需要的是一个从对象到动作的连接,以及如何在动作表函数中适当地为key写入对象

我需要的帮助是在按钮中连接所选对象 行动

[按钮添加目标:自我操作:@selector(DetailEvent1:)forControlEvents:UIControlEventTouchUpInside]

然后在新的视图控制器上显示该信息


我真的不知道你在问什么,如果你澄清一下,我会尽力帮助你:)

下面是一个例子,当选择一个项目时,会显示一个操作表。我只是使用所选项目的索引路径,但我假设您需要保存一些其他数据,以便操作表代理可以使用它

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    NSString *str = [NSString stringWithFormat:@"Call number %d", indexPath.row];

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:(id < UIActionSheetDelegate >)self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:str, nil];

    [actionSheet showInView:self.view];
}
-(void)collectionView:(UICollectionView*)collectionView didSelectItemAtIndexPath:(NSIndexPath*)indexPath{
NSString*str=[NSString stringWithFormat:@“呼叫号码%d”,indexPath.row];
UIActionSheet*actionSheet=[[UIActionSheet alloc]initWithTitle:nil委托:(id)自取消按钮:@“取消”销毁按钮:nil其他按钮:str,nil];
[actionSheet showInView:self.view];
}

我用查询中的新行更新了代码,但是它无法说明社交活动是未声明的,不管它是什么?我还更改了操作以执行操作表,而不是新的视图控制器。我现在需要的是一个从对象到动作的连接,以及如何在动作表函数中适当地为键写入对象。我试图做的是运行一个查询,向您显示10个最近的存储位置,当您单击UIButton集合视图中的一个按钮时,它将打开一个动作表,以便您可以有一个选项调用该位置。希望helpsI用一个简单的例子编辑了答案。别忘了连接UICollectionViewDelegate协议。@选择器(社交:)