[英]iOS xcode Button isn't linking.
我的主故事板上有一个按钮。 我很确定它已正确链接,但是当我运行模拟器并按下按钮时,它什么也没做。 我不知道该怎么打开Safari的按钮?
Viewcontroller.h
#import <UIKit/UIKit.h>
@interface testViewController : UIViewController
- (IBAction)openSafari:(id)sender;
@end
Viewcontroller.m
#import "testViewController.h"
@interface testViewController ()
@end
@implementation testViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (IBAction)openSafari:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"www.google.com"]];
}
@end
URL需要方法和地址,因此请尝试@“ http://www.google.com”。 为了证明您的操作是否正确,请从该方法中打印一条日志消息(或使用断点)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.