******ios6 和ios7的适配

ILBaseTableViewController.m

- (void)viewDidLoad
{
[super viewDidLoad];
// 244 243 241 // 设置tableView的背景颜色
// ios6 backgroundView > backgroundColor
self.tableView.backgroundView = nil;
self.tableView.backgroundColor = ILColor(, , ); // 设置组间距
self.tableView.sectionHeaderHeight = ;
self.tableView.sectionFooterHeight = ; #warning 适配ios7的组间距
if (ios7) { self.tableView.contentInset = UIEdgeInsetsMake(-, , , );
} }

************ILSettingCell.m

#import "ILSettingCell.h"

#import "ILSettingItem.h"

#import "ILSettingArrowItem.h"
#import "ILSettingSwitchItem.h"
#import "ILSettingLabelItem.h" @interface ILSettingCell() @property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UISwitch *switchView;
@property (nonatomic, strong) UILabel *labelView; @property (nonatomic, weak) UIView *divider; @end @implementation ILSettingCell - (UIView *)divider
{
if (_divider == nil) {
if (!ios7) { // 不是ios7才需要创建分割线
UIView *divider = [[UIView alloc] init];
divider.backgroundColor = [UIColor blackColor];
divider.alpha = 0.2; [self.contentView addSubview:divider];
_divider = divider;
}
} return _divider;
} - (UILabel *)labelView
{
if (_labelView == nil) {
_labelView = [[UILabel alloc] init];
_labelView.bounds = CGRectMake(, , , );
_labelView.textColor = [UIColor redColor];
_labelView.textAlignment = NSTextAlignmentRight;
}
return _labelView;
} - (UIImageView *)imgView
{
if (_imgView == nil) {
_imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CellArrow"]];
}
return _imgView;
} - (UISwitch *)switchView
{
if (_switchView == nil) { _switchView = [[UISwitch alloc] init];
}
return _switchView;
} - (void)setItem:(ILSettingItem *)item
{
_item = item; // 1.设置cell的子控件的数据
[self setUpData]; // 2.设置右边视图
[self setUpAccessoryView]; } // 设置cell的子控件的数据
- (void)setUpData
{
if (_item.icon.length) { self.imageView.image = [UIImage imageNamed:_item.icon];
}
self.textLabel.text = _item.title; self.detailTextLabel.text = _item.subTitle;
} // 设置右边视图
- (void)setUpAccessoryView
{
if ([_item isKindOfClass:[ILSettingArrowItem class]]) { // 箭头
self.accessoryView = self.imgView;
self.selectionStyle = UITableViewCellSelectionStyleDefault;
}else if ([_item isKindOfClass:[ILSettingSwitchItem class]]){ // Switch
self.accessoryView = self.switchView;
self.selectionStyle = UITableViewCellSelectionStyleNone;
}else if ([_item isKindOfClass:[ILSettingLabelItem class]]){
self.accessoryView = self.labelView; ILSettingLabelItem *labelItem = (ILSettingLabelItem *)_item;
self.labelView.text = labelItem.text;
self.selectionStyle = UITableViewCellSelectionStyleDefault;
}else{
self.accessoryView = nil;
self.selectionStyle = UITableViewCellSelectionStyleDefault;
}
} #warning 快速创建cell
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
static NSString *ID = @"cell";
ILSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:ID ]; if (cell == nil) {
cell = [[ILSettingCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
} return cell;
} #warning 判断分割线是否需要显示
- (void)setIndexPath:(NSIndexPath *)indexPath
{
_indexPath = indexPath; self.divider.hidden = indexPath.row == ; } - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
// 237 233 218 // 设置背景
[self setUpBg];
// 清空子视图的背景
[self setSubViews]; } return self;
}
#warning 设置背景
- (void)setUpBg
{
// 设置背景图片
UIView *bg = [[UIView alloc] init];
bg.backgroundColor = [UIColor whiteColor];
self.backgroundView = bg; // 设置选中的背景图片
UIView *selectedBg = [[UIView alloc] init];
selectedBg.backgroundColor = ILColor(, , );
self.selectedBackgroundView = selectedBg;
} #warning 清空子控件的背景颜色
- (void)setSubViews
{
self.textLabel.backgroundColor = [UIColor clearColor];
self.detailTextLabel.backgroundColor = [UIColor clearColor];
} #warning 适配ios6的cell
- (void)setFrame:(CGRect)frame
{ if (!ios7) { frame.size.width += ;
frame.origin.x -= ;
} [super setFrame:frame];
} #warning 设置分割线的frame
- (void)layoutSubviews
{
[super layoutSubviews]; CGFloat dividerX = self.textLabel.frame.origin.x;
CGFloat dividerY = ;
CGFloat dividerH = ;
CGFloat dividerW = ; self.divider.frame = CGRectMake(dividerX, dividerY, dividerW, dividerH);
} @end

***********短信 分享,邮件分享ILShareViewController.h

#import "ILShareViewController.h"

#import "ILSettingItem.h"

#import "ILSettingArrowItem.h"
#import "ILSettingGroup.h" #import "UMSocial.h" #import <MessageUI/MessageUI.h> @interface ILShareViewController ()<MFMessageComposeViewControllerDelegate,MFMailComposeViewControllerDelegate> @property (nonatomic, assign) int age; @end @implementation ILShareViewController - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. // 0组
[self addGroup0]; } - (void)addGroup0
{
// 0组
ILSettingArrowItem *sina = [ILSettingArrowItem itemWithIcon:@"WeiboSina" title:@"新浪分享" ];
sina.option = ^{
[[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToSina] content:@"分享内嵌文字" image:nil location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
if (response.responseCode == UMSResponseCodeSuccess) {
NSLog(@"分享成功!");
}
}]; }; ILSettingItem *sms = [ILSettingArrowItem itemWithIcon:@"SmsShare" title:@"短信分享"];
__weak ILShareViewController *share = self;
sms.option = ^{
MFMessageComposeViewController *vc = [[MFMessageComposeViewController alloc] init];
// 设置短信内容
vc.body = @"吃饭了没?";
// 设置收件人列表
vc.recipients = @[@"", @""];
// 设置代理
vc.messageComposeDelegate = share; share.age;
// 显示控制器
[share presentViewController:vc animated:YES completion:nil]; }; ILSettingItem *mail = [ILSettingArrowItem itemWithIcon:@"MailShare" title:@"邮件分享"];
mail.option = ^{
// 不能发邮件
if (![MFMailComposeViewController canSendMail]) return; MFMailComposeViewController *vc = [[MFMailComposeViewController alloc] init]; // 设置邮件主题
[vc setSubject:@"会议"];
// 设置邮件内容
[vc setMessageBody:@"今天下午开会吧" isHTML:NO];
// 设置收件人列表
[vc setToRecipients:@[@"643055866@qq.com"]];
// 设置抄送人列表
[vc setCcRecipients:@[@"1234@qq.com"]];
// 设置密送人列表
[vc setBccRecipients:@[@"56789@qq.com"]]; // 添加附件(一张图片)
UIImage *image = [UIImage imageNamed:@"阿狸头像"];
NSData *data = UIImagePNGRepresentation(image);
[vc addAttachmentData:data mimeType:@"image/png" fileName:@"阿狸头像.png"];
// 设置代理
// vc.mailComposeDelegate = self;
// // 显示控制器
// [self presentViewController:vc animated:YES completion:nil]; }; ILSettingGroup *group0 = [[ILSettingGroup alloc] init]; group0.items = @[sina,sms,mail]; [self.dataList addObject:group0];
} - (void)dealloc
{
NSLog(@"dealloc");
} // 当你取消发送短信的时候就会调用
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissViewControllerAnimated:YES completion:nil];
} - (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
ILShareViewController .h
#import "ILBaseTableViewController.h"

@interface ILShareViewController : ILBaseTableViewController

@end

*****拨打电话ILAboutViewController.m

#import "ILAboutViewController.h"

#import "ILSettingItem.h"

#import "ILSettingArrowItem.h"
#import "ILSettingGroup.h" #import "ILAboutHeaderView.h" @interface ILAboutViewController ()
@property (nonatomic, strong) UIWebView *webView;
@end @implementation ILAboutViewController - (UIWebView *)webView
{
if (_webView == nil) { _webView = [[UIWebView alloc] init]; }
return _webView;
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. // 0组
[self addGroup0]; self.tableView.tableHeaderView = [ILAboutHeaderView headerView]; } - (void)addGroup0
{ // 0组
ILSettingArrowItem *score = [ILSettingArrowItem itemWithIcon:nil title:@"评分支持" destVcClass:nil];
score.option = ^{
// 评分
NSString *appid = @"";
NSString *str = [NSString stringWithFormat:
@"itms-apps://itunes.apple.com/cn/app/id%@?mt=8", appid];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]; }; ILSettingItem *tel = [ILSettingArrowItem itemWithIcon:nil title:@"客服电话"];
tel.subTitle = @"020-83568090";
tel.option = ^{
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"tel://10010"]]]; }; ILSettingGroup *group0 = [[ILSettingGroup alloc] init];
group0.items = @[score,tel]; [self.dataList addObject:group0]; } @end

******帮助界面

#import "ILHelpViewController.h"

#import "ILSettingCell.h"

#import "ILSettingItem.h"

#import "ILSettingArrowItem.h"
#import "ILSettingSwitchItem.h" #import "ILSettingGroup.h" #import "ILHtml.h" #import "ILHtmlViewController.h" #import "ILNavigationController.h" @interface ILHelpViewController ()
@property (nonatomic, strong) NSMutableArray *htmls;
@end @implementation ILHelpViewController - (NSMutableArray *)htmls
{
if (_htmls == nil) {
_htmls = [NSMutableArray array]; NSString *fileName = [[NSBundle mainBundle] pathForResource:@"help.json" ofType:nil];
NSData *data = [NSData dataWithContentsOfFile:fileName]; NSArray *jsonArr = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; for (NSDictionary *dict in jsonArr) {
ILHtml *html = [ILHtml htmlWithDict:dict];
[_htmls addObject:html];
}
}
return _htmls;
} - (void)viewDidLoad
{
[super viewDidLoad];
// 0组
[self addGroup0]; } - (void)addGroup0
{ // 0组
NSMutableArray *items = [NSMutableArray array];
for (ILHtml *html in self.htmls) {
ILSettingArrowItem *item = [ILSettingArrowItem itemWithIcon:nil title:html.title destVcClass:nil];
[items addObject:item];
} ILSettingGroup *group0 = [[ILSettingGroup alloc] init];
group0.items = items; [self.dataList addObject:group0]; } // 重写tableView的点击
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// 取出每一行对应的Html模型
ILHtml *html = self.htmls[indexPath.row]; ILHtmlViewController *htmlVc = [[ILHtmlViewController alloc] init];
htmlVc.title = html.title;
htmlVc.html = html; ILNavigationController *nav = [[ILNavigationController alloc] initWithRootViewController:htmlVc]; [self presentViewController:nav animated:YES completion:nil];
} @end

********webview 的页面

#import "ILHtmlViewController.h"

#import "ILHtml.h"

@interface ILHtmlViewController ()<UIWebViewDelegate>

@end

@implementation ILHtmlViewController

- (void)loadView
{
self.view = [[UIWebView alloc] init];
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. self.view.backgroundColor = [UIColor whiteColor]; UIBarButtonItem *cancle = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStyleBordered target:self action:@selector(cancle)];
self.navigationItem.leftBarButtonItem = cancle; UIWebView *webView = (UIWebView *)self.view; // 加载资源包里面的Html
NSURL *url = [[NSBundle mainBundle] URLForResource:_html.html withExtension:nil]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; webView.delegate = self; [webView loadRequest:request]; } // 加载完网页调用
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSString *js = [NSString stringWithFormat:@"window.location.href = '#%@';",_html.ID];
[webView stringByEvaluatingJavaScriptFromString:js];
} - (void)cancle
{
// 回到上一个控制器
[self dismissViewControllerAnimated:YES completion:nil]; }
@end

.h

#import <UIKit/UIKit.h>

@class ILHtml;
@interface ILHtmlViewController : UIViewController @property (nonatomic, strong) ILHtml *html; @end

IOS彩票第三天界面的更多相关文章

  1. IOS彩票第二天设置界面(1)

    ****跳转到设置界面 - (IBAction)setting:(id)sender { // 创建设置口控制器 ILSettingTableViewController *settingVc = [ ...

  2. IOS彩票第二天设置界面(2)

    *********代码的抽取ILBaseTableViewController.h #import <UIKit/UIKit.h> @interface ILBaseTableViewCo ...

  3. IOS炫酷的引导界面

    代码地址如下:http://www.demodashi.com/demo/11246.html 一.准备工作 1.先用时ps工具制作好图片 2.然后计算好每张图片通过滑动视图的偏移量来改变图片的位置 ...

  4. iOS开发UI篇—iOS开发中三种简单的动画设置

    iOS开发UI篇—iOS开发中三种简单的动画设置 [在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView b ...

  5. iOS push过去的时候界面不能完全退出

    iOS push过去的时候界面不能完全退出 解决方法:设置self.view.backgroundcolor 1. initWithFrame方法是什么?  initWithFrame方法用来初始化并 ...

  6. Android 仿PhotoShop调色板应用(三) 主体界面绘制

    版权声明:本文为博主原创文章,未经博主允许不得转载. Android 仿PhotoShop调色板应用(三) 主体界面绘制    关于PhotoShop调色板应用的实现我总结了两个最核心的部分:   1 ...

  7. XMPPFrameWork IOS 开发(三)登录

    原始地址:XMPPFrameWork IOS 开发(三) XMPP中常用对象们: XMPPStream:xmpp基础服务类 XMPPRoster:好友列表类 XMPPRosterCoreDataSto ...

  8. C#开发PACS医学影像处理系统(三):界面布局之工具栏

    工具栏布局采用WPF中Grid作为容器,按钮采用自定义样式和图标,并采用Separator分割线: XAML设计器代码: 其中  Style="{StaticResource ButtonS ...

  9. iOS彩票项目--第三天,搭建竞技场和发现,搭建幸运选号和我的彩票界面

    一.竞技场搭建--UISegmentedControl的使用 // 重写 自定义控制器的view - (void)loadView { UIImageView *imgView = [[UIImage ...

随机推荐

  1. java.lang.instrument使用

    Java在1.5引入java.lang.instrument,你可以由此实现一个Javaagent,通过此agent来修改类的字节码即改变一个类. 程序启动之时启动代理(pre-main) 通过jav ...

  2. bpl 包的编写和引用

    转载:http://www.cnblogs.com/gxch/archive/2011/04/23/bpl.html 为什么要使用包? 答案很简单:因为包的功能强大.设计期包(design-time ...

  3. iOS开发实用干货——强化你的Xcode控制台

    f(x) 郑秀晶程序员不要整天看代码,偶尔也要看看风景?? www.90168.org先上一张我的Xcode控制台的图片让你们感受一下 酷炫控制台 是不是觉得很酷?不过仅仅是酷还是远远不够的,当你点击 ...

  4. Codeforces Round #336 (Div. 2)

    水 A - Saitama Destroys Hotel 简单的模拟,小贪心.其实只要求max (ans, t + f); #include <bits/stdc++.h> using n ...

  5. LightOJ1283 Shelving Books(DP)

    题目 Source http://www.lightoj.com/volume_showproblem.php?problem=1283 Description You are a librarian ...

  6. ccc prefab

    MonsterPrefab.js var Helpers = require('Helpers'); cc.Class({ extends: cc.Component, properties: { s ...

  7. 20145308刘昊阳 《Java程序设计》第8周学习总结

    20145308刘昊阳 <Java程序设计>第8周学习总结 教材学习内容总结 第15章 通用API 15.1 日志 15.1.1 日志API简介 java.util.loggging包提供 ...

  8. 洛谷 P1462 通往奥格瑞玛的道路 Label: 最小化最大值 && spfa (存多条边示例)

    题目背景 在艾泽拉斯大陆上有一位名叫歪嘴哦的神奇术士,他是部落的中坚力量 有一天他醒来后发现自己居然到了联盟的主城暴风城 在被众多联盟的士兵攻击后,他决定逃回自己的家乡奥格瑞玛 题目描述 在艾泽拉斯, ...

  9. 洛谷 P1031 均分纸牌 Label:续命模拟QAQ

    题目描述 有 N 堆纸牌,编号分别为 1,2,…, N.每堆上有若干张,但纸牌总数必为 N 的倍数.可以在任一堆上取若于张纸牌,然后移动. 移牌规则为:在编号为 1 堆上取的纸牌,只能移到编号为 2 ...

  10. Javascript与当前项目的思考

      主体 分为以下三部分,能力.经验有限,欢迎拍砖. 1.低效的代码 2.面向对象的重构重复利用代码 3.调试的经验总结 第一部分 日常中低效的代码 加载和运行 <html> <he ...