网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 iphone屏幕旋转的例子
内容
    先在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
    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
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/13 23:46:34