iOS天气预报模块总结
来源:互联网 发布:15年股灾真相知乎 编辑:程序博客网 时间:2024/06/05 00:37
下面总结一下我的第一个iOS项目中天气预报模块遇到的细节问题:
1、当多个不同的控制器要进入同一个控制器,且要保持该控制器的信息和数据是一致的,即是该控制类的同一个对象,该怎么办?
刚开始时,想了很久不知道该怎么办,其实用地个简单的单例方法,就能很容易地解决:
在.h文件声明该单例方法为类方法,在.m文件中声明一个静态的该类类型的变量(用于在单例方法中返回),再实现单例方法:
+ (WeatherMoreCityController *)instanceOfMoreCityController
{
if(moreCityController ==nil)
{
moreCityController = [[WeatherMoreCityControlleralloc] init];
}
returnmoreCityController;
}
moreCityController就是该静态变量。
2、视图类的subviews属性(NSArray类型),中包含该视图的所有子视图, demo:
int size =[self.subviewscount];
for(int i=size-1;i>=0;i--)
{
[self.subviews[i]removeFromSuperview];
}
3、故事板中根导航器导航到一个标签控制器,标签控制器中有两个标签,其控制器是两个导航控制器,两个导航控制器后面分别导航到两个实际控制界面的控制器,代码为:
WeatherPrimarViewController *primarViewController = [[WeatherPrimarViewControlleralloc] init];
WeatherMoreCityController *moreCityController = [WeatherMoreCityControllerinstanceOfMoreCityController];
UINavigationController *navPrimarViewController = [[UINavigationControlleralloc] initWithRootViewController:primarViewController];
UINavigationController *navMoreCityController = [[UINavigationControlleralloc] initWithRootViewController:moreCityController];
UIImage* tabBarImage = [UIImageimageNamed:@"top_bg.png"];
[self.navigationController.navigationBarsetBackgroundImage: tabBarImage forBarMetrics:UIBarMetricsDefault];
primarViewItem = [[UITabBarItemalloc]initWithTitle:@""image:[UIImageimageNamed:@"weather_forecast_on1.png"]tag:0];
moreCityItem = [[UITabBarItemalloc]initWithTitle:@""image:[UIImageimageNamed:@"weather_more_on1.png"]tag:1];
[primarViewItemsetFinishedSelectedImage:[UIImageimageNamed:@"weather_forecast_on1.png"]withFinishedUnselectedImage:[UIImageimageNam ed:@"weather_forecast1.png"]];
[moreCityItem setFinishedSelectedImage:[UIImageimageNamed:@"weather_more_on1.png"]withFinishedUnselectedImage:[UIImageimageNamed:@"w eather_more1.png"]];
navPrimarViewController.tabBarItem =primarViewItem;
navMoreCityController.tabBarItem =moreCityItem;
NSArray *controllers = [NSArrayarrayWithObjects:navPrimarViewController,navMoreCityController,nil];
tabBarController.viewControllers = controllers;
- iOS天气预报模块总结
- 天气预报模块的实现
- iOS BLE 模块开发总结
- 天气预报模块的实现分析
- IOS天气预报(美化)
- iOS天气预报Demo
- iOS开发:简易天气预报
- 天气预报调用网址总结
- 天气预报API总结
- 项目总结-天气预报(电视)
- 天气预报项目学习总结
- 天气预报项目学习总结
- iOS开发—解析天气预报
- 天气预报
- 天气预报
- 天气预报
- 天气预报
- 天气预报
- Disruptor一个开源的高效内存无锁队列
- MySQL执行计划解读
- 完全二叉树根据节点个数求叶子个数
- 正则表达式
- 北大dean的session
- iOS天气预报模块总结
- sqoop向hdfs,hive,hbase导入数据
- OpenCV c接口与c++接口
- Combinations
- mysql获取一个表格的所有字段
- Python的threading模块
- 【线程】Java线程(2)-线程安全概述
- Python正则表达式指南
- hadoop发生的问题集锦