Jump to content
Sign in to follow this  
Moneybag

[Resolvido] Objective C (xcode) trocar de views por codigo

Recommended Posts

Moneybag

Boas

Fiz uma pequena aplicaçao para testar a troca de visualizaçao entre 2 views quando se carrega num botao. Mas em vez de criar a ligacao pelo storyboard quero criar programando o botao à mao. Mas tou a ter um erro nao sei do que :confused: E como estou a começar nesta liguagem nao sei se estou a fazer da melhor maneira.

lq7x.png

viewcontroller.h

//
// ViewController.h
// switchView
//
// Created by Bernardo Ascensão on 21/10/13.
// Copyright (c) 2013 Bernardo Ascensão. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{

}
- (IBAction)btnEntrar:(id)sender;
@end

viewcontroller.m

//
// ViewController.m
// switchView
//
// Created by Bernardo Ascensão on 21/10/13.
// Copyright (c) 2013 Bernardo Ascensão. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)btnEntrar:(id)sender {
UIStoryboard * mainStoryboard = [uIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"menuViewController"];
[self presentViewController:vc animated:YES completion:NULL];
}
@end

Erro Output

hurm.png

Share this post


Link to post
Share on other sites
KTachyon

Parece-me que o nome do teu storyboard é "Main" e não "MainStoryboard".


“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Share this post


Link to post
Share on other sites
Moneybag

Parece-me que o nome do teu storyboard é "Main" e não "MainStoryboard".

:thumbsup: mais uma vez obrigado !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.