我的应用程序中有一个按钮,单击该按钮会将您带到存储在 plist 中的企业网站。我可以获得使用此代码的按钮:
-(IBAction)search:(id)sender{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]];
}
现在如何操作此代码以从已建立的 plist 调用网站。
最佳答案
从 p-list 中获取链接字符串。
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]];
NSString * urlString = dictionary[@"TheKeyPath"]; // theKeyPath referring to the key that you assigned to the url string in the p-list
那么就很简单了...
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
关于ios - Xcode 中来自 Plist 的超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19471091/