Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.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_Iphone_Objective C - Fatal编程技术网

Ios 连接并使用带有自定义单元格的表内按钮

Ios 连接并使用带有自定义单元格的表内按钮,ios,iphone,objective-c,Ios,Iphone,Objective C,我面临一个小问题。我有一张有两门课的桌子。使用UIViewcontroller作为根视图,在其内部我有一个UITableViewCell。我定制了一个单元格,里面有按钮 问题:如何连接和使用按钮 我已经尝试了下面提到的一些东西和解决方法。。但是没有用。最后,我感到非常沮丧,我想试着用一个标签,如果可能的话,用它的标签让它充当一个按钮 1) 我尝试将按钮连接到根视图,但在构建时导致情节提要错误 2) 我尝试将按钮连接到UITableViewCell。没关系,但在我想在-(iAction)b中使用的

我面临一个小问题。我有一张有两门课的桌子。使用
UIViewcontroller
作为根视图,在其内部我有一个
UITableViewCell
。我定制了一个单元格,里面有按钮

问题:如何连接和使用按钮

我已经尝试了下面提到的一些东西和解决方法。。但是没有用。最后,我感到非常沮丧,我想试着用一个标签,如果可能的话,用它的标签让它充当一个按钮

1) 我尝试将按钮连接到根视图,但在构建时导致情节提要错误

2) 我尝试将按钮连接到
UITableViewCell
。没关系,但在我想在
-(iAction)b中使用的代码中,为按钮单击了
,该按钮是:

-(IBAction)btnclicked
{
        profileViewController *second = [self.storyboard instantiateViewControllerWithIdentifier:@"AnotherView"];
        [self presentViewController:second animated:YES completion:nil];
} 
当我使用此代码时,会收到这些错误消息

对于方法内的第一行: 在类型为“AnotherView”的对象上未找到属性“storyboard”

第二行: “OtherUsersCell”的不可见@interface声明选择器“presentViewController:second animated:YES completion:”

我用上面的代码连接我的视图,而不是故事板序列


任何帮助都将不胜感激。

我找到了!。以下是我所做的,首先在这个方法中:

 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath     *)indexPath
如下面所示,我给我的按钮添加了一个标签(在我的例子中是-16),并确定了一个选择器,该选择器指向当按钮被录制时应该运行的方法,在我的例子中,方法名称是
ButtonClicked

UIButton *Button= (UIButton*)[self.view viewWithTag: -16];
Button.tag = -16;
[Button addTarget:self action:@selector(ButtonClicked) forControlEvents:UIControlEventTouchUpInside];
以下是我的方法代码:

-(void) ButtonClicked
{
        buyViewController *second = [self.storyboard instantiateViewControllerWithIdentifier:@"MyOtherView"];
        [self presentViewController:second animated:YES completion:nil];
}

我在不同类型的对象上遇到了相同的问题,到目前为止,在所有情况下,我都使用了标记,该标记可以从属性检查器分配给视图中的任何对象。我希望这能帮助任何面临同样问题的人

这个男人还是不认识我们。我也会犯同样的错误。谢谢你