Navigate to another view from Appdelegate through a UIButton
I have the following issue. I have made a UIButton in my Appdelegate and I want that button navigate me to another ViewController. I already made a connection from my Storyboard, this connection is a type Modal Segue. I thought that performSegueWithIdentifier will do the job but it gives me the following error "has no segue with identifier 'showCamera' ". And I'm pretty sure that I have made that Identifier trough the Storyboard.
let camera = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
camera.addTarget(self, action: "takePicture:", forControlEvents: .TouchUpInside);
//this function works
func takePicture(sender: UIButton!){
println("Open Camera")
//this throws an error
self.window?.rootViewController?.performSegueWithIdentifier("showCamera", sender: self)
}
ios iphone swift uibutton uistoryboardsegue
add a comment |
I have the following issue. I have made a UIButton in my Appdelegate and I want that button navigate me to another ViewController. I already made a connection from my Storyboard, this connection is a type Modal Segue. I thought that performSegueWithIdentifier will do the job but it gives me the following error "has no segue with identifier 'showCamera' ". And I'm pretty sure that I have made that Identifier trough the Storyboard.
let camera = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
camera.addTarget(self, action: "takePicture:", forControlEvents: .TouchUpInside);
//this function works
func takePicture(sender: UIButton!){
println("Open Camera")
//this throws an error
self.window?.rootViewController?.performSegueWithIdentifier("showCamera", sender: self)
}
ios iphone swift uibutton uistoryboardsegue
Why init from AppDelegate?
– Mohammad Nurdin
Mar 25 '15 at 9:09
What do you suggest? @Dato'MohammadNurdin I have made a custom Button in my UITabbar so i can call the UIPickerController cautiously. I've to make that button in the appdelegate because my tabbar is initialized there. If you have any other suggestion that would be more then welcome.
– Navid
Mar 25 '15 at 9:18
add a comment |
I have the following issue. I have made a UIButton in my Appdelegate and I want that button navigate me to another ViewController. I already made a connection from my Storyboard, this connection is a type Modal Segue. I thought that performSegueWithIdentifier will do the job but it gives me the following error "has no segue with identifier 'showCamera' ". And I'm pretty sure that I have made that Identifier trough the Storyboard.
let camera = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
camera.addTarget(self, action: "takePicture:", forControlEvents: .TouchUpInside);
//this function works
func takePicture(sender: UIButton!){
println("Open Camera")
//this throws an error
self.window?.rootViewController?.performSegueWithIdentifier("showCamera", sender: self)
}
ios iphone swift uibutton uistoryboardsegue
I have the following issue. I have made a UIButton in my Appdelegate and I want that button navigate me to another ViewController. I already made a connection from my Storyboard, this connection is a type Modal Segue. I thought that performSegueWithIdentifier will do the job but it gives me the following error "has no segue with identifier 'showCamera' ". And I'm pretty sure that I have made that Identifier trough the Storyboard.
let camera = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
camera.addTarget(self, action: "takePicture:", forControlEvents: .TouchUpInside);
//this function works
func takePicture(sender: UIButton!){
println("Open Camera")
//this throws an error
self.window?.rootViewController?.performSegueWithIdentifier("showCamera", sender: self)
}
ios iphone swift uibutton uistoryboardsegue
ios iphone swift uibutton uistoryboardsegue
edited Nov 15 '18 at 6:24
Cœur
18.5k9110148
18.5k9110148
asked Mar 25 '15 at 8:40
NavidNavid
3001720
3001720
Why init from AppDelegate?
– Mohammad Nurdin
Mar 25 '15 at 9:09
What do you suggest? @Dato'MohammadNurdin I have made a custom Button in my UITabbar so i can call the UIPickerController cautiously. I've to make that button in the appdelegate because my tabbar is initialized there. If you have any other suggestion that would be more then welcome.
– Navid
Mar 25 '15 at 9:18
add a comment |
Why init from AppDelegate?
– Mohammad Nurdin
Mar 25 '15 at 9:09
What do you suggest? @Dato'MohammadNurdin I have made a custom Button in my UITabbar so i can call the UIPickerController cautiously. I've to make that button in the appdelegate because my tabbar is initialized there. If you have any other suggestion that would be more then welcome.
– Navid
Mar 25 '15 at 9:18
Why init from AppDelegate?
– Mohammad Nurdin
Mar 25 '15 at 9:09
Why init from AppDelegate?
– Mohammad Nurdin
Mar 25 '15 at 9:09
What do you suggest? @Dato'MohammadNurdin I have made a custom Button in my UITabbar so i can call the UIPickerController cautiously. I've to make that button in the appdelegate because my tabbar is initialized there. If you have any other suggestion that would be more then welcome.
– Navid
Mar 25 '15 at 9:18
What do you suggest? @Dato'MohammadNurdin I have made a custom Button in my UITabbar so i can call the UIPickerController cautiously. I've to make that button in the appdelegate because my tabbar is initialized there. If you have any other suggestion that would be more then welcome.
– Navid
Mar 25 '15 at 9:18
add a comment |
1 Answer
1
active
oldest
votes
Don't add any view components in appDelegate. Just set UIViewController as rootViewController of window. Then add buttons to the UIViewController.Like this,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
[self.window makeKeyAndVisible];
ViewController *vc = [[ViewController alloc]init];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = navController;
// Override point for customization after application launch.
return YES;
}
In ViewController.m add your required UI components.
I'm working in Swift the example you provided is in Objective C. Swift doesnt have Implementation files.
– Navid
Mar 25 '15 at 9:57
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29250903%2fnavigate-to-another-view-from-appdelegate-through-a-uibutton%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Don't add any view components in appDelegate. Just set UIViewController as rootViewController of window. Then add buttons to the UIViewController.Like this,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
[self.window makeKeyAndVisible];
ViewController *vc = [[ViewController alloc]init];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = navController;
// Override point for customization after application launch.
return YES;
}
In ViewController.m add your required UI components.
I'm working in Swift the example you provided is in Objective C. Swift doesnt have Implementation files.
– Navid
Mar 25 '15 at 9:57
add a comment |
Don't add any view components in appDelegate. Just set UIViewController as rootViewController of window. Then add buttons to the UIViewController.Like this,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
[self.window makeKeyAndVisible];
ViewController *vc = [[ViewController alloc]init];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = navController;
// Override point for customization after application launch.
return YES;
}
In ViewController.m add your required UI components.
I'm working in Swift the example you provided is in Objective C. Swift doesnt have Implementation files.
– Navid
Mar 25 '15 at 9:57
add a comment |
Don't add any view components in appDelegate. Just set UIViewController as rootViewController of window. Then add buttons to the UIViewController.Like this,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
[self.window makeKeyAndVisible];
ViewController *vc = [[ViewController alloc]init];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = navController;
// Override point for customization after application launch.
return YES;
}
In ViewController.m add your required UI components.
Don't add any view components in appDelegate. Just set UIViewController as rootViewController of window. Then add buttons to the UIViewController.Like this,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
[self.window makeKeyAndVisible];
ViewController *vc = [[ViewController alloc]init];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = navController;
// Override point for customization after application launch.
return YES;
}
In ViewController.m add your required UI components.
answered Mar 25 '15 at 9:51
Jaffer SheriffJaffer Sheriff
731525
731525
I'm working in Swift the example you provided is in Objective C. Swift doesnt have Implementation files.
– Navid
Mar 25 '15 at 9:57
add a comment |
I'm working in Swift the example you provided is in Objective C. Swift doesnt have Implementation files.
– Navid
Mar 25 '15 at 9:57
I'm working in Swift the example you provided is in Objective C. Swift doesnt have Implementation files.
– Navid
Mar 25 '15 at 9:57
I'm working in Swift the example you provided is in Objective C. Swift doesnt have Implementation files.
– Navid
Mar 25 '15 at 9:57
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29250903%2fnavigate-to-another-view-from-appdelegate-through-a-uibutton%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why init from AppDelegate?
– Mohammad Nurdin
Mar 25 '15 at 9:09
What do you suggest? @Dato'MohammadNurdin I have made a custom Button in my UITabbar so i can call the UIPickerController cautiously. I've to make that button in the appdelegate because my tabbar is initialized there. If you have any other suggestion that would be more then welcome.
– Navid
Mar 25 '15 at 9:18