I create a window in which I take custom view. Here is my PROJECT.
Credetials : modijecky#gmail.com, Password : 2
Just sign in through credetials and click on second option in side bar and then click on login.
Here my code to add xib view in my viewcontroller of my main view
- (IBAction)watchClicked:(id)sender {
//id animator = [[ContactUsVC alloc] init];
ContactUsVC* vc = [[ContactUsVC alloc] initWithNibName:#"ContactUsVC" bundle:nil];
vc.view.frame = self.view_main.bounds;
[self.custom_view addSubview:vc.view];
[self.view_main setEnabled:NO];
}
I put a button on ContactUsVC and when I click app crashed. I dont understand why simple click is not happen.
Here is Error
Exception Name: NSInvalidArgumentException
Description: -[_NSImageAuxiliary btn_click_phone_no:]: unrecognized selector sent to instance 0x6080002c10a0
User Info: (null)
Place breakpoint before this line
ContactUsVC* vc = [[ContactUsVC alloc] initWithNibName:#"ContactUsVC" bundle:nil];
And check whether button's action is executed or not.By crash description it seems Image Button. Have you place any image on button?
Related
i'm a new developper with storyboard.i try to make a app with a slide-out menu.
To do this, i use the library : SWRevealViewController and the tutorial : http://www.appcoda.com/ios-programming-sidebar-navigation-menu/ .
i follow the tutorial, but i load the application, i'have this error :
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '*** -[__NSArrayM
insertObject:atIndex:]: object cannot be nil'
my app crash on this line :
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
how can i set self.revealViewController ?
here my storyboard UPDATED:
to understand my app, startviewController is used to download and store data, after downloading, the mainViewcontroller is showed.
i want my slide out menu on my mainviewcontroller, but i cant not do.
here the code i add to my mainviewController viewdidload :
- (void)viewDidLoad
{
[super viewDidLoad];
self.contentView.autoresizesSubviews = YES;
_sharedUser = [User sharedUser];
///slide out menu
// Change button color
//SWRevealViewController *revealViewController = [self.navigationController.storyboard instantiateViewControllerWithIdentifier:#"RevealViewController"];
_sidebarButton.tintColor = [UIColor redColor];
// Set the side bar button action. When it's tapped, it'll show up the sidebar.
_sidebarButton.target = self.revealViewController;
_sidebarButton.action = #selector(revealToggle:);
// Set the gesture
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
//end slide out
self.contentView.backgroundColor = [UIColor cyanColor];
if (_sharedUser.tokenString) {
}
else{
[self showHomeWithoutLogginView];
}
}
I'm looking at the tutorial you are following. According to your screenshot, there are some stuff missing in your storyboard.
The RevealViewController should be connected with two controllers: a front viewController (for displaying content) and a rear viewController (for showing the navigation menu):
Credits for the image: http://www.appcoda.com/ios-programming-sidebar-navigation-menu/
Those connections (segues) should be marked as "reveal view controller" and each of them have to be named accordingly: "sw_front" and "sw_rear".
Then you have to add the menu items in the navigation menu (rear view controller) and connect each cell to the corresponding viewController, give the segues a name and mark them as a SWRevealViewController class. You may want to connect the front view controller to the viewController you want to be shown first.
I strongly suggest you make the tutorial as it is. I think I used it in the past and it worked pretty well. If you have any doubt about it don't hesitate to ask.
Best of lucks!
SOLVED
thanks to leandro !
here the code who is need in my staviewcontroller who solved my problem:
SWRevealViewController *sideBar = [self.navigationController.storyboard instantiateViewControllerWithIdentifier:#"SWRevealViewController"];
[self.navigationController pushViewController:sideBar animated:YES];
Are you using the latest version of the SWRevealViewController? The AppCoda tutorial is outdated, and SWReveal has great sample on Git.
Check your segue identifier and class on your storyboard. Have you set sw_front and sw_rear? Also, in the latest version, your segue for setting the Menu / Front View should be: SWRevealViewControllerSegueSetController and not the old SWRevealViewControllerSegue.
EDIT:
Also note that calling [self.revealController panGestureRecognizer]; is enough to enable the gesture; no need for an additional gesture.
EDIT:
Try initializing like this:
MenuViewController *menuVC = [self.storyboard instantiateViewControllerWithIdentifier:#"MenuViewController"];
UINavigationController *frontNavigationController = [self.storyboard instantiateViewControllerWithIdentifier:#"MainNavigationController"];
SWRevealViewController *revealViewController = [[SWRevealViewController alloc] initWithRearViewController:menuVC frontViewController:frontNavigationController];
EDIT:
Can you try adding an action to your Menu Button like this:
[menuButton addTarget:self.revealViewController action:#selector(revealToggle:)
forControlEvents:UIControlEventTouchUpInside];
I developed app for iOS and i trie catch the event in a button, that button is in a xib and i create a method when touch up inside.
and i present de view the following form
DetailNoticiaController *detail = [[DetailNoticiaController alloc] init];
[self.view addSubview:detail.view];
detail.view contain the button, when the button is pressed, the app crashed and not show the error.
The problem is that detail deallocates as you don't save it somewhere. You may try code below:
DetailNoticiaController *detail = [[DetailNoticiaController alloc] init];
[self addChildViewController:detail];
[self.view addSubview:detail.view];
Helpful link - "Creating Custom Container View Controllers"
I am developing a library for a iOS app that will authenticate the users on the basis of the credential entered by them.
What I am doing is that, from a view controller say TestViewController I am setting a new view controller LoginScreenViewController on top of TestViewController when user taps a button by using the following code.
LoginScreenViewController * LoginScreen = [[LoginScreenViewController alloc] initWithNibName:nil bundle:nil];
[self.view addSubview:LoginScreen.view];
This LoginScreenViewController contains a Cancel button, on which I want to remove the LoginScreenViewController. For this I am using following code
[self.view removeFromSuperview];
the problem is when I am executing this code, my app is crashing.
Since my LoginScreenViewController is defined by the Library, I want it to be independent of the caller's implementation.
EDIT:
In LoginScreenViewController.m I have used following code to add an event handler to the cancel button.
[button addTarget:self action:#selector(CancelButtonHandler:) forControlEvents:UIControlEventTouchUpInside];
The app is crashing when I am tapping the Cancel button. Even if the CancelButtonHandler does not contain any line of code.
You are trying to remove wrong view. To remove LoginScreen view do:
[LoginScreen.view removeFromSuperview];
My ipad project is master-detail view based. There is a button on detail view's toolbar, when user tap on the button, it popup a popover view to show four buttons (as menu). Three of buttons' actions are like the following (the three buttons show three different model form sheets):
- (void) showOnlineSgf
{
NSLog(#"showOnlineSgf");
TGOOnlineSgfViewController *dlg =
[[TGOOnlineSgfViewController alloc] initWithNibName:#"TGOOnlineSgfViewController"
bundle:nil];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:dlg];
[nav setModalPresentationStyle:UIModalPresentationFormSheet];
[self presentViewController:nav animated:YES completion:nil];
dlg = nil;
nav = nil;
}
The other button's action is to show a MFMailComposeViewController. Code is like the following:
- (void) emailCurrentGame
{
NSLog(#"email current game");
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[self presentModalViewController:picker animated:YES];
picker = nil;
}
The weird behavior is that when I tap the button what should execute showOnlineSgf(), but emailCurrentGame() is actually executed. When I set a breakpoint in showOnlineSgf(), it's hit, and step by step, each statement in showOnlineSgf() is executed. But the result on screen is a MFMainComposeViewController shows up.
I know this question is hard to answer. Any idea is appreciated.
Check your outlet connection of your UIButton that triggers showOnlineSgf. Most likely you copy pasted your UIButton in Interface Builder, which causes it to copy its assigned action as well. Then you've connected your other action, resulting in your UIButton having two actions.
To resolve the problem, simply disconnect your UIButton that triggers showOnlineSgf from the emailCurrentGame action.
Sounds like you copy pasted in the interface builder an already connected button. Check if the button has more than one action assigned.
I have a table view and i put a ToolBar button so when button is clicked open a Map View.
When I click the button my application crash, so I tried this:
MapViewController *mvc = [[MapViewController alloc]initWithNibName:#"MapViewController" bundle:nil];
// NSArray *categories = nil;
switch ([indexPath row]){
case 0:
[self.navigationController pushViewController:svc animated:YES];
....
And when I tap a corresponding cell it open new view and my mapView is working like a charm
But when I put same in the Button action method my application crash.
Any ideas?
My guess is that you pass the wrong selector when you connect the button to the action.
If you have created the button programattically.
Don't forget to add it to the view.
The selector should look something like this: `[button addTarget:self action:#selector(pressButton1:) forControlEvents:UIControlEventTouchUpInside];
Note the : in pressButton1: