我的主故事板上有一个按钮。我很确定它已正确链接,但是当我运行模拟器并按下按钮时,它什么也没做。我缺少什么来获得打开 Safari 的按钮?
视图控制器.h
#import <UIKit/UIKit.h>
@interface testViewController : UIViewController
- (IBAction)openSafari:(id)sender;
@end
视图控制器.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