惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
S
Securelist
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tenable Blog
I
Intezer
G
GRAHAM CLULEY
Spread Privacy
Spread Privacy
T
Tor Project blog
V
Vulnerabilities – Threatpost
NISL@THU
NISL@THU
L
Lohrmann on Cybersecurity
Schneier on Security
Schneier on Security
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
S
Security @ Cisco Blogs
The Register - Security
The Register - Security
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
L
LangChain Blog
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
小众软件
小众软件
The Hacker News
The Hacker News
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
U
Unit 42
博客园 - 叶小钗
Attack and Defense Labs
Attack and Defense Labs
Webroot Blog
Webroot Blog
大猫的无限游戏
大猫的无限游戏
Apple Machine Learning Research
Apple Machine Learning Research
H
Hackread – Cybersecurity News, Data Breaches, AI and More
aimingoo的专栏
aimingoo的专栏
T
Troy Hunt's Blog
V
Visual Studio Blog
P
Proofpoint News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
A
Arctic Wolf
T
The Exploit Database - CXSecurity.com
宝玉的分享
宝玉的分享
Vercel News
Vercel News
D
DataBreaches.Net
P
Palo Alto Networks Blog
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - 墨墨

Windows Phone 7中配置gmail, 使用outlook 同步邮件,日历,联系人等 iPhone 闭包应用 objective-c的TextFields输入完成后关闭键盘和触摸背景关闭键盘 第一个iPhone程序之Hello World 第一个objective-c程序 iPhone自动化测试 visual studio 2010 ultimate 下载 suse下设置IP的两种方法 freebsd下之简单安装python ibatis.net私人学习资料,勿下(加密) ibatisnet高级查询 Python相关中文学习资料 搭建python的web开发环境 windows下 使用Aptana搭建Python开发环境 使用SharpZipLib 解压zip 2012年真的是世界末日吗?_全球关注 关于生成静态页--终极解决方案 Json格式类的转换相关代码 Extjs 登录界面源码
iPhone屏幕旋转的例子
墨墨 · 2010-10-26 · via 博客园 - 墨墨

先在interface builder上放上6个rectbutton,竖放,一排三个

然后我们下面来看代码

.h文件代码

 1 //
 2 //  AutoSizeViewController.h
 3 //  AutoSize
 4 //
 5 //  Created by Scott on 10-10-26.
 6 //  Copyright 2010 __MyCompanyName__. All rights reserved.
 7 //
 8 
 9 #import <UIKit/UIKit.h>
10 
11 @interface AutoSizeViewController : UIViewController {
12     UIButton *button1;
13     UIButton *button2;
14     UIButton *button3;
15     UIButton *button4;
16     UIButton *button5;
17     UIButton *button6;
18 }
19 
20 @property (nonatomic,retain) IBOutlet UIButton *button1;
21 @property (nonatomic,retain) IBOutlet UIButton *button2;
22 @property (nonatomic,retain) IBOutlet UIButton *button3;
23 @property (nonatomic,retain) IBOutlet UIButton *button4;
24 @property (nonatomic,retain) IBOutlet UIButton *button5;
25 @property (nonatomic,retain) IBOutlet UIButton *button6;
26 @end
27 

下面我们看.m的代码

//
//  AutoSizeViewController.m
//  AutoSize
//
//  Created by Scott on 10-10-26.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "AutoSizeViewController.h"

@implementation AutoSizeViewController

@synthesize button1;
@synthesize button2;
@synthesize button3;
@synthesize button4;
@synthesize button5;
@synthesize button6;

/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
    if (interfaceOrientation==UIInterfaceOrientationPortrait || interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) {
        button1.frame=CGRectMake(20, 20, 125, 125);
        button2.frame=CGRectMake(175, 20, 125, 125);
        button3.frame=CGRectMake(20, 168, 125, 125);
        button4.frame=CGRectMake(175, 168, 125, 125);
        button5.frame=CGRectMake(20, 315, 125, 125);
        button6.frame=CGRectMake(175, 315, 125, 125);
    }else {
        button1.frame=CGRectMake(20, 20, 125, 125);
        button2.frame=CGRectMake(20, 155, 125, 125);
        button3.frame=CGRectMake(177, 20, 125, 125);
        button4.frame=CGRectMake(177, 155, 125, 125);
        button5.frame=CGRectMake(328, 20, 125, 125);
        button6.frame=CGRectMake(328, 155, 125, 125);
    }

}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.button1=nil;
    self.button2=nil;
    self.button3=nil;
    self.button4=nil;
    self.button5=nil;
    self.button6=nil;
    [super viewDidUnload];
}

- (void)dealloc {
    [button1 release];
    button2.release;
    button3.release;
    button4.release;
    button5.release;
    button6.release;
    [super dealloc];
}

@end