Storyboard UIViewController not appear - objective-c

I recently started using storyboard.
I have the main viewcontroller, which by code must call another viewcontroller.
in storyboard, I created a "segue" that goes from the first to the second controller, with the identifier "segueToSignSelection."
in the main viewcontroller, when I need to call up the second viewcontroller, insert this code:
[self performSegueWithIdentifier:#"segueToSignSelection" sender:self];
that calls this method:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:#"segueToSignSelection"])
{
signSelectionViewController = (SignSelectionViewController*)[segue destinationViewController];
[self presentModalViewController:segue.destinationViewController animated:YES];
[segue.destinationViewController test];
}
}
in the second controller, the test method is invoked. But the view does not appear. What could be the problem?
Thanks

Related

How can I cancel a prepareForSegue if the nested IF doesn't pass?

If the third nested 'IF' doesn't pass I would like the segue not to run. How can I do that?
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"showStudentMainPage"]) {
if (![self.studentEmailField.text isEqualToString:#""] && ![self.studentMDCID.text isEqualToString:#""]) {
if ([self.data checkStudentEmail:self.studentEmailField.text checkStudentID:self.studentMDCID.text]) {
StudentMainPageViewController *dest = [segue destinationViewController];
dest.rowInDB = self.rowInDBHere;
}
}
}
}
(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender.
This method is only Notifies the view controller that a segue is about to be performed.You can not prevent segue.The default implementation of this method does nothing. Subclasses override this method and use it to configure the new view controller prior to it being displayed.
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/#//apple_ref/occ/instm/UIViewController/performSegueWithIdentifier:sender:
check with this May be it will help
To stop segue and show alert
You should override shouldPerformSegueWithIdentifier on your UIViewController and put your logic there. You cannot cancel a segue inside prepareForSegue. Take a look at the UIViewController reference for more details.

Performwithsegue and programatically switching views - Objective-C

I am having a problem, I want to change to another viewcontroller when a timer expires and this works with this code:
- (IBAction)Akkoord:(id)sender {
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:#"Innameformulier"];
[self presentViewController:vc animated:YES completion:nil];
[self performseguewithidentifier:#"nextcontroller"]
}
But when I use this, my variables in my prepareforsegue method are not passing. How can I do this? I already tried [self performseguewithidentifier] but this is not working.
my preparforsegue code is:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
Innameformulier *IForm = [segue destinationViewController];
IForm.SignatureTransport = _drawImage.image;
IForm.KlantnaamInname = _Klantnaamtransport;
}
How can I call this function to happen on the timer?
In Interface Builder, select the View Controller from which you want to fire a segue, CTRL-drag from it to the destination View Controller and create a segue.
Select the segue, open the Attributes Inspector and create an Identifier for it.
Go back to your View Controller Class that fires the segue and if you don't already have it commented, add the method prepareForSegue:
In your prepareForSegue: method you should have something like the following:
- (void)prepareForSegue:(UIStoryboardSegue *)segue {
if ([segue.identifier isEqualToString:#"XXXX"]) {
DestinationVC *dVC = segue.destinationViewController;
dVC.attribute1 = self.anAttribute;
dVC.attribute2 = self.anotherAttribute;
}
}
And now you can fire the segue by calling [self performSegueWithIdentifier:#"XXXX"].
Note: you can also fire an action segue from an UIControl subclass like UIButton
OK, what you are doing here is bypassing the segue completely. You need to do something like this...
- (IBAction)Akkoord:(id)sender {
[self performseguewithidentifier:#"nextcontroller"]
}
This is all you need to do. The segue will then create the nextController for you and then the code inside prepareForSegue will pass the variables across.
If you want it on a timer then you just need to set up a timer and when it expires you can run...
[self performseguewithidentifier:#"nextcontroller"]
As long as you have a segue with this identifier then it will work anywhere. Ever after a timer.

display next view controller in stroboard

i am new to ios development
i have created a slash screen that check internet connection when application load and that is my rootviewcontroller.
i have created a next view using uiviewcontroller in same storyboard name Main_iphone
the storyboard id of viewcontroller is "HomeScreen".
the question is how do i jump on "Homescreen" from "SplashScreen" when internet connection found
I had created the function to jump on next screen-
[self perform:#selector(goToNextView) withObject:nil afterDelay:3];
-(void) goToNextView{
UIStroyboard *iphone=[UIStoryBoardWithName:#"Main_iphone" bundel: nil];
}
Thank you for your time
Try this :
-(void) goToNextView{
[self performSegueWithIdentifier:#"HomeScreen" sender:self];
}
If, you want to set some value use this :
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:#"HomeScreen"])
{
// do here
}
}

How to segue from a custom delegate and datasource

I have a view with 2 tableviews in it. This view has the controller PlayerDetailController
Now to control the 2 tableviews I have 2 other controllers.
tablePlayersDataSourceDelegate
tablePlayerNewsDataSourceDelegate
I ctrl-dragged from the PlayerDetail view to the newsView to make a segue. In my tablePlayerDataSourceDelegate I've the following methods to preform this segue.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:#"showPlayerDetailNews" sender:indexPath];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = (NSIndexPath *)sender;
PlayerNews *news = [_tableSource objectAtIndex:indexPath.row]; // ask NSFRC for the NSMO at the row in question
if ([segue.identifier isEqualToString:#"show detail"]) {
[segue.destinationViewController setImageURL:[NSURL URLWithString:news.image]];
[segue.destinationViewController setNewsTitle:news.title];
[segue.destinationViewController setNewsDescription:news.content];
[segue.destinationViewController setNewsCopy:news.image_copyright];
[segue.destinationViewController setNewsUrl:news.url];
[segue.destinationViewController setNewsShortDescription:news.summary];
}
}
But when I test I get the following error.
** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<tblPlayerNewsDatasourceDelagete: 0x1e5e44c0>) has no segue with identifier 'showPlayerDetailNews''
I get why this is giving the error. Because the playerDetail view uses the class playerDetailController and I am trying to do te segue in the tablePlayerNewsDelegate class. Do you maybe know a way to work around it?
EDIT
Here you see a picture of what I am talking about
So you can see the two tableviews in the playerDetailView. When a cell in the bottom tableview is clicked it should go to the next view.
EDIT2
This is what I do in my playerDetailController to fill up my tableview. I've put this in my viewDidLoad.
tabelPlayerNews=[[tblPlayerNewsDatasourceDelagete alloc]init];
[tabelPlayerNews setTableSource:_newsArray];
tblNews.dataSource=tabelPlayerNews;
tblNews.delegate=tabelPlayerNews;
tabelPlayerNews.view=tabelPlayerNews.tableView;
I'm not sure whether I understand that or not but in general....
To use performSegueWithIdentifier: the drag for the segue should start at the controller that will make the call, not at a view or other object. I think that's what the error message is telling you: assuming there's a segue called "showPlayerDetailNews" in your storyboard, it doesn't belong to the correct object.

iOS 5, Storyboards, ARC: Navigation Controller doesn't work in custom delegate

The prequel for this question is here. Now I've got another problem. I cannot navigate despite of the didSelectRowAtIndexPath getting invoked while tapping on cell
KMList *detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"KMs"];
detailViewController.fromPeriod=self.fromPeriod;
detailViewController.period1=self.entityID;
[self.navigationController pushViewController:detailViewController animated:YES];
What the problem. Is it because I am kind of off the storyboard?
P.S No warnings or errors. Just nothing happens.
Thanks in advance.
You should not push the new view controller in code when using a storyboard. This is done automatically. Instead make a push-Segue in Interface Builder and give it an identifier. Then in your view controller you overwrite prepareForSegue:sender: and check for the identifier like this:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"<your segue identifier>"]) {
KMList *detailViewController = [segue destinationViewController];
detailViewController.fromPeriod=self.fromPeriod;
detailViewController.period1=self.entityID;
}
}