簡體   English   中英

iOS xcode按鈕未鏈接。

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM