开发者

iphone switch views with buttons, SecondView over FirstView

to all im newbie developer and trying to create my first iPhone app, sorry my english not good

i trying to make 2 views and the second view display over first view, but the second view is not full screen, is 320x400 i cut 80pixels, to see the buttons from the first view... and i making that with tutorials from one book, but in book he making 1 button on first view and 1 another button in the second view... and i need 2 buttons on the first view, and can't make it. please help me... i think is very easy but i dont know how to..

with this code make in book what i reading


**FirstView.h**

#import UIKit/UIKit.h

@interface FirstView : UIViewController { }

/--- declare an action for the Button view ---/

-(IBAction) goToSecondView:(id) sender;

@end

**FirstView.m**

#import "FirstView.h"

#import "SecondView.h"

@implementation FirstView

SecondView *secondView;

-(IBAction) goToSecondView:(id) sender{

secondView = [[SecondView alloc] initWithNibName:nil bundle:nil]; [self.view addSubview:secondView.view];

}

-(void)dealloc { [SecondView release];

[super dealloc]; }

**SecondView.h**

#import @interface SecondView : UIViewController { }

/*--- action for the Return button --- */

-(IBAction) goToFirstView:(id) sender;

@end

**SecondView.m**

#import "SecondView.h"

@implementation SecondView

-(IBAction) goToFirstView:(id) sender {

[self.view removeF开发者_开发百科romSuperview];}

And after linking on Interface Builder one button (goToSecondView) on the first view, and one button on the SecondView(goToFirstView).... and i want to make this two buttons on the first view.

Help me please! , thank you.


Just put another button in the first view and move your code of goToFirstView to the FirstView controller. Then, change where you coded [self.view removeFromSuperview]; by a [secondView.view removeFromSuperview];

I suggest you to read some tutorials of how the views and viewcontrollers are designed in iPhone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜