iOS 开启个人热点后屏幕的适配问题
2016-02-25 11:20
507 查看
//iOS 在开启个人热点后会调用此方法
- (void)viewWillLayoutSubviews
//
// ViewController.m
// test_Person_Hotspot_01
//
// Created by admin on 1/28/16.
// Copyright © 2016 jeffasd. All rights reserved.
//
#import "ViewController.h"
#define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width/2
#define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height
@interface ViewController ()
{
UIButton *button;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
button = [UIButton
buttonWithType:UIButtonTypeCustom];
// [[UIScreen mainScreen] bounds].size.width/2;
// button.frame = CGRectMake(SCREEN_WIDTH, SCREEN_HEIGHT - 20 -50, 50, 50);
button.frame =
CGRectMake(SCREEN_WIDTH,
self.view.frame.size.height
- 20 -50,
50, 50);
// button.bounds = CGRectMake(SCREEN_WIDTH, SCREEN_HEIGHT - 20 -50, 50, 50);
// button.bounds = CGRectMake(50, 50, 50, 42);
button.backgroundColor = [UIColor
cyanColor];
[self.view
addSubview:button];
self.tabBar.frame =
CGRectMake(0,
self.view.frame.size.height-40,
320, 40);
}
- (void)viewWillAppear:(BOOL)animated{
[super
viewWillAppear:animated];
self.view.backgroundColor = [UIColor
whiteColor];
}
- (void)viewDidAppear:(BOOL)animated{
[super
viewDidAppear:animated];
self.view.backgroundColor = [UIColor
whiteColor];
}
- (void)viewWillDisappear:(BOOL)animated{
[super
viewWillDisappear:animated];
self.view.backgroundColor = [UIColor
whiteColor];
}
//iOS 在开启个人热点后会调用此方法
- (void)viewWillLayoutSubviews{
button.frame =
CGRectMake(SCREEN_WIDTH,
self.view.frame.size.height
- 20 -50,
50, 50);
[super
viewWillLayoutSubviews];
self.view.backgroundColor = [UIColor
redColor];
[self.view
layoutSubviews];
NSLog(@"the Screen is %@",
NSStringFromCGRect([[UIScreen
mainScreen] bounds]));
NSLog(@"the VC view frame is %@",
NSStringFromCGRect(self.view.frame));
// button.frame = CGRectMake(SCREEN_WIDTH, SCREEN_HEIGHT - 20 -50, 50, 50);
// button.frame = CGRectMake(SCREEN_WIDTH, self.view.frame.size.height - 20 -50, 50, 50);
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
- (void)viewWillLayoutSubviews
//
// ViewController.m
// test_Person_Hotspot_01
//
// Created by admin on 1/28/16.
// Copyright © 2016 jeffasd. All rights reserved.
//
#import "ViewController.h"
#define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width/2
#define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height
@interface ViewController ()
{
UIButton *button;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
button = [UIButton
buttonWithType:UIButtonTypeCustom];
// [[UIScreen mainScreen] bounds].size.width/2;
// button.frame = CGRectMake(SCREEN_WIDTH, SCREEN_HEIGHT - 20 -50, 50, 50);
button.frame =
CGRectMake(SCREEN_WIDTH,
self.view.frame.size.height
- 20 -50,
50, 50);
// button.bounds = CGRectMake(SCREEN_WIDTH, SCREEN_HEIGHT - 20 -50, 50, 50);
// button.bounds = CGRectMake(50, 50, 50, 42);
button.backgroundColor = [UIColor
cyanColor];
[self.view
addSubview:button];
self.tabBar.frame =
CGRectMake(0,
self.view.frame.size.height-40,
320, 40);
}
- (void)viewWillAppear:(BOOL)animated{
[super
viewWillAppear:animated];
self.view.backgroundColor = [UIColor
whiteColor];
}
- (void)viewDidAppear:(BOOL)animated{
[super
viewDidAppear:animated];
self.view.backgroundColor = [UIColor
whiteColor];
}
- (void)viewWillDisappear:(BOOL)animated{
[super
viewWillDisappear:animated];
self.view.backgroundColor = [UIColor
whiteColor];
}
//iOS 在开启个人热点后会调用此方法
- (void)viewWillLayoutSubviews{
button.frame =
CGRectMake(SCREEN_WIDTH,
self.view.frame.size.height
- 20 -50,
50, 50);
[super
viewWillLayoutSubviews];
self.view.backgroundColor = [UIColor
redColor];
[self.view
layoutSubviews];
NSLog(@"the Screen is %@",
NSStringFromCGRect([[UIScreen
mainScreen] bounds]));
NSLog(@"the VC view frame is %@",
NSStringFromCGRect(self.view.frame));
// button.frame = CGRectMake(SCREEN_WIDTH, SCREEN_HEIGHT - 20 -50, 50, 50);
// button.frame = CGRectMake(SCREEN_WIDTH, self.view.frame.size.height - 20 -50, 50, 50);
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
相关文章推荐
- nagios
- IOS异步获取数据并刷新界面dispatch_async的使用方法
- iOS 提交错误
- iOS Crash日志
- iOS 让启动页面延迟的方法
- iOS开发-调试(debug)
- iOS中的谓词(NSPredicate)使用
- iOS数据持久化
- iOS开发---如何给类别增加属性
- iOS开发xib控件删不掉,修改xib运行不发生改变,修改xib不管用
- iOS基础动画教程
- iOS 上线 LaunchImage、Icon、iTunes connect的屏幕快照——iOS 上线相关(一)
- iOS开发笔记--iOS图解多线程
- iOS获取设备电量、内存、容量
- 初学者要了解的第三方库
- iOS 设计模式 - 代理模式
- iOS获取设备全局信息方法总结(如信号,电量,设备标示)
- IOS银联支付
- iOS 设计模式 - 单例模式
- IOS银联支付