在相关网站首页加载到手机上浏览网页

news/2024/5/16 6:47:08/文章来源:https://xindizhiyin2014.blog.csdn.net/article/details/17687443

学了一段时间的IOS相信大家一定非常的想编写一个软件使自己的手机能够访问你指定的网站。其实呢这个实现起来非常的简单,下面我会为大家分享一下代码,另外还要实现网络的状态,就是那个白色的菊花,由于第一个实在是太简单了,我就写在一块了,大家一看就明白了。


具体的代码如下:

HHLAppDelegate.h

#import <UIKit/UIKit.h>@class HHLViewController;@interface HHLAppDelegate : UIResponder <UIApplicationDelegate>@property (strong, nonatomic) UIWindow *window;@property (strong, nonatomic) HHLViewController *viewController;@property (strong,nonatomic) UINavigationController *myNaVC;@end

HHLAppDelegate.m

#import "HHLAppDelegate.h"#import "HHLViewController.h"@implementation HHLAppDelegate- (void)dealloc
{[_window release];[_viewController release];[super dealloc];
}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];// Override point for customization after application launch.self.viewController = [[[HHLViewController alloc] initWithNibName:@"HHLViewController" bundle:nil] autorelease];UINavigationController *pNaVC = [[UINavigationController alloc]initWithRootViewController:self.viewController];self.myNaVC = pNaVC;[pNaVC release];self.window.rootViewController = self.myNaVC;[self.window makeKeyAndVisible];return YES;
}- (void)applicationWillResignActive:(UIApplication *)application
{// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}- (void)applicationDidEnterBackground:(UIApplication *)application
{// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}- (void)applicationWillEnterForeground:(UIApplication *)application
{// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}- (void)applicationDidBecomeActive:(UIApplication *)application
{// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}- (void)applicationWillTerminate:(UIApplication *)application
{// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}@end


HHLViewController.h

#import <UIKit/UIKit.h>@interface HHLViewController : UIViewController<UIWebViewDelegate>{
@privateUIWebView *myWebView;UIActivityIndicatorView *myIndicatorView;}
@end

HHLViewController.m

#import "HHLViewController.h"@interface HHLViewController ()@end@implementation HHLViewController- (void)dealloc
{[myIndicatorView release];if (myWebView.loading) {[myWebView stopLoading];}myWebView.delegate = nil;//苹果文档中推荐,release前需要如此编写[myWebView release];[super dealloc];}
- (void)viewDidLoad
{[super viewDidLoad];self.title = @"明确显示通信状态";myWebView = [[UIWebView alloc]init];myWebView.delegate =self;myWebView.frame = self.view.bounds;myWebView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;myWebView.scalesPageToFit = YES;

//UIWebViewscalePageToFit属性设置为YES,这样Web页面就会根据屏幕大小自动伸缩。

[self.view addSubview:myWebView];[self.navigationController setNavigationBarHidden:NO animated:YES];[self.navigationController setToolbarHidden:NO animated:YES];//在工具条中追加活动指示器myIndicatorView = [[UIActivityIndicatorView alloc]init];myIndicatorView.frame =CGRectMake(0, 0, 50, 50);UIBarButtonItem *indicator = [[[UIBarButtonItem alloc] initWithCustomView:myIndicatorView]autorelease];UIBarButtonItem *adjustment = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]autorelease];NSArray *buttons = [NSArray arrayWithObjects:adjustment,indicator,adjustment, nil];[self setToolbarItems:buttons animated:YES];}- (void)viewDidAppear:(BOOL)animated {[super viewDidAppear:animated];//Web页面显示NSURLRequest *myRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com/"]];[myWebView loadRequest:myRequest];[self updateViewConstraints]; }- (void)webViewDidStartLoad:(UIWebView *)webView {[myIndicatorView startAnimating]; }- (void)webViewDidFinishLoad:(UIWebView *)webView {[myIndicatorView stopAnimating];}- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {[myIndicatorView stopAnimating]; } - (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated. }@end

由于代码很简单,如果大家有哪些不太清楚的,可以到官方文档看看,或者百度一下就OK了,

运行后,具体的效果如下图:

     

怎么样哦,效果不赖吧



本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_789453.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

优化网站设计(四):对资源启用压缩

前言 网站设计的优化是一个很大的话题,有一些通用的原则,也有针对不同开发平台的一些建议。这方面的研究一直没有停止过&#xff0c;我在不同的场合也分享过这样的话题。 作为通用的原则&#xff0c;雅虎的工程师团队曾经给出过35个最佳实践。这个列表请参考 Best Practices fo…

JiaSale 购物按钮 WordPress 插件:让你博客瞬间变成电商网站

什么是 JiaSale 长期关注我爱水煮鱼的读者可能知道我还有一个专门销售 WordPress 插件和主题的站点&#xff1a;WPJAM 应用商城&#xff0c;通过支付宝购买&#xff0c;成功之后就可以直接附件了&#xff0c;全程无需人工介入&#xff0c;我只在后面收钱即可&#xff0c; 。 …

规划以主机命名的网站集 (Windows SharePoint Services)

摘自MSDN&#xff1a;http://technet.microsoft.com/zh-cn/library/cc288637.aspx Windows SharePoint Services 3.0 既支持以主机命名的网站集&#xff0c;也支持基于路径的网站集。以主机命名的网站集提供可缩放的宿主解决方案&#xff0c;其中每个网站集都有不同的主机名。这…

android 清华镜像,清华镜像网站下载android源码并编译

8种机械键盘轴体对比本人程序员&#xff0c;要买一个写代码的键盘&#xff0c;请问红轴和茶轴怎么选&#xff1f;下载android源码方法&#xff1a;我的系统是ubuntu 18.04&#xff0c;主要参考了blog通过清华大学镜像下载Android源码并编译源码&#xff0c;通过国内镜像网站下载…

利用WINXP IIS服务自建ASP网站的步骤

利用WINXP IIS服务自建ASP网站的步骤 1. 安装搭建IIS服务环境(在可能需要下载IIS安装包)&#xff0c;控制面板&#xff0c;利用“添加/删除程序”的“添加/删除Windows组件”功能&#xff0c;安装“Internet信息服务”组件&#xff08;如Internet信息服务管理单元、公用文件、万…

干货分享!12款响应式的移动网站模板免费下载

如果你打算开发网站&#xff0c;你想要关注的第一件事就是网站的外观和感觉。另外用户体验很重要&#xff0c;现在是属于移动互联的时代&#xff0c;用户有可能通过移动设备浏览你的网站&#xff0c;因此同样重要的是要考虑你的网站在移动端的使用体验。 这个特殊的列表包含一组…

建站篇——百度地图

关于如何在网页中加入百度地图&#xff0c;其实并没有想象中那么复杂&#xff0c;因为&#xff0c;这是一个开源的时代。下面简单介绍一下如何在网页中加入百度地图。为什么是简单介绍一下呢&#xff1f;因为是真的很简单…… 一、打开地图生成器 这个地址不好找&#xff0c;建…

想学网站运营?我教你啊!(下)

创见干货&#xff1a; 在上一章节&#xff0c;我们讨论了如何对内容进行取舍和把握。其实这还并不是网站运营的真正秘诀。真正想要在未来赢得市场&#xff0c;就必须掌握 A/B 测试。这就是本文最后一个章节&#xff0c;也是最重要的一部分内容。 其中有一些策略是如此的重要&am…

【分享资料 】01 开发者网站

【分享资料 】01 开发者网站百度开发搜索&#xff1a;https://kaifa.baidu.com/home 我们常用的国内搜索网站&#xff0c;考虑到大多数网民的整体素质&#xff0c;所以搜素很低级而且充斥着广告 国外的网站在这方面好很多&#xff0c;但是全英文搜索消耗精力实在太多了 而且效果…

图片浏览器每次只能打开一张图片_资源素材第049期:我做视频常用的图片网站与工具分享!...

大家好&#xff0c;我是热爱后期的老蒋。上周我给大家分享的我平时制作视频用到的图片网站与工具的文章深受大家的喜欢——我做视频常用的音频音效网站与工具分享&#xff01;所以本周跟大家聊一聊视频制作中可以用到的图片网站与工具。如果觉得好的话&#xff0c;建议点赞&…

小米8ios图标包下载_你想的 ICON 图标,在这些网站都可以找到了

在应用界面中图标的存在&#xff0c;会给用户一个良好第一印象&#xff0c;这个挺重要的。但是从零开始开发图标需要大量的时间和金钱。在你的网站上使用图标可以让你有效地与你的访问者交流:它们增加了可读性&#xff0c;突出了重要的内容&#xff0c;加强了功能或特性&#x…

wordpress上传图片慢_WordPress网站不利于SEO是真的么?如何做好网站SEO

首先这个结论个人觉得是不靠谱的&#xff01;网上似乎有这种说法&#xff0c;具体不清楚从哪来的。反正wordpress网站高权重的站点还是能一找一大把的。那么wordpress站长如何做好seo呢&#xff0c;简单总结了一下几点1、友情链接并不是不重要了&#xff0c;该做的还是得做各种…

python实现登录抓取_python requests 模拟登陆网站,抓取数据

抓取页面数据的时候&#xff0c;有时候我们需要登陆才可以获取页面资源&#xff0c;那么我们需要登陆以后才可以跳转到对应的资源页面&#xff0c;那么我们需要通过模拟登陆&#xff0c;登陆成功以后再次去抓取对应的数据。 首先我们需要通过手动方式来登陆一下&#xff0c;查看…

网站迁移到新服务器的步骤_新手使用使用阿里云服务器搭建网站的具体操作步骤...

新手使用使用阿里云服务器搭建网站的具体操作步骤阿里云服务器是阿里云的重要支柱产品&#xff0c;阿里云——阿里巴巴集团旗下公司&#xff0c;是全球领先的云计算及人工智能科技公司。提供云服务器、云数据库、云安全、云企业应用等云计算服务&#xff0c;以及大数据、人工智…

ajax收录问题_关于网站进行SEO的7大问题你知道吗?

关于网站进行SEO的7大问题你知道吗&#xff1f;一、什么是seo&#xff1f;seo的作用是什么&#xff1f;SEO(Search Engine Optimization)汉译为搜索引擎优化。是一种利用搜索引擎的规则提高网站的自然排名的方法&#xff0c;可使其在行业内占据领先地位&#xff0c;获得品牌收益…

对石家庄铁道大学网站UI的分析

作为我们团队的PM&#xff0c;老师对我们提出了一些额外的要求&#xff0c;所以我发表这篇博客来谈一下对石家庄铁道大学网站UI的分析。首先&#xff0c;PM 对项目所有功能的把握, 特别是UI。最差的UI, 体现了团队的组织架构&#xff1b;其次, 体现了产品的内部结构&#xff1b…

米的建站日记(2014年12月19日)

今天要做一个pdf在线预览的功能&#xff0c;同事帮我找到了一个FlexPaper的插件&#xff0c; 这位大神有详细的使用教程&#xff1a;http://www.cnblogs.com/qinpeifeng107/archive/2011/08/29/2158879.html 说下我使用过程中遇到的问题&#xff0c;一开始FlexPaperViewer.swf的…

百度网盘链接在线解析网站_最近很热闹啊,免登陆百度网盘高速链接转换工具...

本文由阿刚同学原创&#xff0c;首发在乐软博客(www.isharepc.com)欢迎关注乐软博客微信公众号“阿刚同学”近期百度网盘可谓相当热闹&#xff0c;前些天最新版的客户端新增了利用闲置宽带兑换下载提速&#xff0c;换言之就是将你的空闲上传宽带组建成特有的传输通道&#xff0…

可以发外链的网站_2019年网站SEO优化还有必要发外链吗?

(文/守护袁昆)曾几何时做SEO的朋友信奉内容为王&#xff0c;外链不皇。疯狂的发外链对网站SEO优化效果非常好&#xff0c;后面百度一系列的算法打击外链作弊&#xff0c;如今网站SEO优化还有必要发外链吗&#xff1f;首先要确定一个观点&#xff0c;外链的作用还是挺大的&#…

使用IntelliJ IDEA开发SpringMVC网站(四)用户管理

使用IntelliJ IDEA开发SpringMVC网站&#xff08;四&#xff09;用户管理 原文:使用IntelliJ IDEA开发SpringMVC网站&#xff08;四&#xff09;用户管理摘要 通过对用户表的管理&#xff0c;更加深入地讲解SpringMVC的操作。 目录[-] 文章已针对IDEA 15做了一定的更新&#xf…