iOS 链接到外部页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16376746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 23:27:36  来源:igfitidea点击:

iOS Link to external page

iosobjective-chyperlinkstoryboard

提问by don

Having read this thread, I'm trying to insert a link to an external web page calling an action upon touch insideon a button (button created in storyboard with xCode 4.6).

阅读此线程后,我正在尝试插入一个指向外部网页的链接,该链接touch inside在按钮上调用操作(使用 xCode 4.6 在情节提要中创建的按钮)。

This is the action:

这是行动:

-(IBAction)outLink:(id)sender {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"https://www.mysite.com/index.php"]];
}

and this the header file (.h):

这是头文件(.h):

@interface MenuViewController : UIViewController <UITableViewDataSource, UITabBarControllerDelegate>{
    IBOutlet UIButton *linkToSite;
}

-(IBAction)outLink;

I have linked the button to the element in the storyboard, and I've linked the action to the Touch Up Insideevent, but I get this error when I click in the simulator on the button:

我已将按钮链接到情节提要中的元素,并将操作链接到Touch Up Inside事件,但是当我在模拟器上单击按钮时出现此错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MenuViewController outLink]: unrecognized selector sent to instance 0x717d340'

采纳答案by Nishant Tyagi

Change method name in .h class and reconnect your outlet for touchupinside event.

更改 .h 类中的方法名称并重新连接您的插座以进行 touchupinside 事件。

-(IBAction)outLink:(id)sender;

Hope it helps you.

希望对你有帮助。