【发布时间】:2017-07-11 15:05:01
【问题描述】:
我从今天开始自己在 IOS 上工作,并开始在现有项目上进行一些小改动。通过界面生成器,我能够添加一个按钮。现在,当点击该按钮时,我想从不同的故事板打开另一个控制器。
这是我的homecell.m
#import "HomeTableViewCell.h"
#import "HostListingsViewController.h"
@implementation HomeTableViewCell
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (IBAction)sharetapped:(id)sender {
// here i want to be redirected to another controller
}
@end
这是我的 homecell.h
#import <UIKit/UIKit.h>
@interface HomeTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *imageViewHome;
@property (weak, nonatomic) IBOutlet UILabel *labelHeading;
@property (weak, nonatomic) IBOutlet UILabel *labelSubHeading;
- (IBAction)sharetapped:(id)sender;
@end
我在谷歌搜索并无法理解。所以我在这里寻求你的帮助。我正在使用 xcode8。
【问题讨论】:
-
简单的解决方案是在 UItabelViewCell 的 "cellForRowAtIndexPath" instread 中将按钮目标添加到 ViewController。您可以在这篇文章中找到解决方案stackoverflow.com/questions/15652133/…
-
@Sandeep Kumar 您链接到的答案是表格视图单元格中有一个按钮。操作员的单元格中没有按钮
-
" 我想从不同的故事板打开另一个控制器" 这是正确的吗?您今天只关注 iOS,但您的项目中已经有多个故事板。第一天似乎有点太早了
-
IBAction 附加到哪个 UIControll 元素?
-
过去有数百个关于如何做到这一点的问题,例如这里有几个只需 5 秒的努力搜索即可找到stackoverflow.com/questions/8924052/…brainwashinc.com/2014/01/08/…
标签: ios objective-c