I am totally new with iOS development.I am just trying to open a new page when user will click on button. But it is not working.I am using this code:
(IBAction)btnOpenNewPage:(UIButton *)sender {
FacebookViewController *ls=[[FacebookViewController alloc] initWithNibName:#"loginSuccessViewController" bundle:nil];
[self.navigationController pushViewController:ls animated:YES];
}
But i don't understand why it is not working! I am using Xcode 6. I think i need to add some parameter or code in other files. Please help me.
if your code there doesn't work then you probably don't have a navigationController. try creating one:
-(IBAction)btnOpenNewPage:(UIButton *)sender {
FacebookViewController *ls=[[FacebookViewController alloc] initWithNibName:#"loginSuccessViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:Is];
[nav pushViewController:ls animated:YES];
}
Related
I have an example of SWRevealViewController from github.
And now I'm tryng to understand, how switch my independent UIViewController to another, which is including in SWRevealViewController.
I read somewhere that this should work:
- (IBAction)action:(UIButton *)sender {
SWRevealViewController *swcontroller = self.revealViewController;
if (swcontroller) {
self.revealViewController.frontViewController = [[UIViewController alloc] init];
}
}
and I create a modal segue from my UIButton to SWRevealViewController.
But it does not work.
Can anybody give an example?
As per my information you need to manually push or pop your view controller in SWRevealViewController.As shown below try this..
- (IBAction)btnActionSalesQuotation:(id)sender{
SWRevealViewController *revealview = self.revealViewController;
SalesQuotationsViewController *Gosalequo=[[SalesQuotationsViewController alloc]initWithNibName:#"SalesQuotationsViewController" bundle:nil];
[revealview pushFrontViewController:Gosalequo animated:YES];
}
That code helped me:
- (IBAction)act:(UIButton *)sender {
SWRevealViewController *sw = [self.storyboard instantiateViewControllerWithIdentifier:#"SWRevealViewController"];
UINavigationController *nav = [self.storyboard instantiateViewControllerWithIdentifier:#"NavigationController"];
[sw setRearViewController:nav];
sw.frontViewController = nav;
[self presentViewController:sw animated:NO completion:nil];
}
I forgot to add setRearViewController
In my code below, I am getting an error saying "Property "navigationController" not found on object of type 'iPhoneFirstPageView *'. This worked before in a different project, but it won't work in this XIB. Any ideas?
-(IBAction)Twitter {
TwitterViewController *twitter = [[TwitterViewController alloc] initWithNibName:nil bundle:nil];
//[self presentViewController:twitter animated:YES completion:NULL];
//[self presentModalViewController:twitter animated:YES];
[self.navigationController pushViewController:TwitterViewController animated:YES];
}
Your first problem is that on this line:
[self.navigationController pushViewController:TwitterViewController animated:YES];
You are trying to push the CLASS TwitterViewControllerrather than your object twitter
Your second problem is that iPhoneFirstPageView is a subclass of UIView and not of UIViewController. The cleanest way for someone new to fix this would be in Xcode to create a new file called iPhoneFirstPageViewController that is a subclass of UIViewController.
The solution setup your initial view controllers as the follow:
iPhoneFirstPageViewController *firstViewController = [[iPhoneFirstPageViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
////Skip to the method you are trying to write. This will be in iPhoneFirstPageViewController.m
-(IBAction)Twitter
{
TwitterViewController *twitter = [[TwitterViewController alloc] init];
[self.navigationController pushViewController:twitter animated:YES];
}
I have a navigation controller that pushes a new viewcontroller. It is working fine in iOS6, but not working fine in iOS5. Btw, I am running on iPhone Simulator.
My code looks like this:
myViewController *newView = [[myViewController alloc] initWithNibName:#"myViewController"
bundle:nil];
[[self navigationController] pushViewController:newView animated:YES];
Tried this as well:
myViewController *newView = [[myViewController alloc] initWithNibName:#"myViewController"
bundle:[NSBundle mainBundle]];
[[self navigationController] pushViewController:newView animated:YES];
Not working.
Tried the solution in this: pushViewController Not Working on iOS 5 (OK on iOS 6).
Not showing the new view controller either, need some guidance on this. Thanks.
Can you try this line just to test if there is some problem with your nib file or not.
myViewController *newView = [[myViewController alloc] init];
[[self navigationController] pushViewController:newView animated:YES];
In - (void)viewDidLoad write self.view.backgroundColor = [UIColor redColor];
just to test whether or not your viewcontroller is pushing.
If you are able to push your View Controller using this method. Then there might be some issue with your nib file.
Do you using storyboard or xib? If you are using storyboard this can help you initwithnibname method in storyboard
I has similar issue. Got it solved by removing 'AutoLayout' constraint inside View to be Pushed.!
I have my iPad ViewController.xib with a button called about us. How to link that button to another page called about us. I have created one XIB file called about.xib. And how do i link that page. Also can I link back to the main viewController. Do i need to create another m or h files?
I have done this code but it doesn't work.
- (IBAction) About {
UIViewController * about = [[UIViewController alloc] initWithNibName:#"About" bundle:nil];
[self.navigationController pushViewController:about animated:YES];
[about release];
}
UIViewController * about = [[UIViewController alloc] initWithNibName:#"About" bundle:nil];
[self presentModalViewController:about animated:YES];
[about release];
i was searching this whole afternoon in hope of solution but i didn't manage to find anything helping me solve the problem.
The problem is, i have no intention of using UINavigationController until a button gets taped, and after that i would like to present view controller containing a navigationcontroller, or reverse, modally. in my search i came across this solution:
MyExampleViewController *vc = [[[MyExampleViewController alloc] initWithNibName:#"MyExample" bundle:nil] autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease];
[self presentModalViewController:navController animated:YES];
which i then used it in my code and found out it is not working, to make sure i started a practice project from viewbased project templet and added this to the first view controller
- (IBAction) buttonGotPreseed{
testino *testController = [[testino alloc] initWithNibName:#"testino" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:testController];
testController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:testController animated:YES];
[nav release];
[testController release];
}
didn't work also, im not seeing the navigation bar up there
any help would be greatly appreciated
You're pushing the root view controller, not the navigation controller itself. Line 5 should be:
[self presentModalViewController:nav animated:YES];