In my app I give a alert, if the user wants to confirm the offer or not.
Now I noticed that if the user hits the home button, the alert stays there & makes my app crash if he would enter anything.
How can I remove the alert (all UIAlerts) when I go to background mode?
Kind regards,
Glenn.
Edit 1:
Basically I a making a offer page. When the user clicks OK, I am showing a UIAlert for extra confirmation.
Now I also have functionality that when a user closes (home button) the app & restarts it, it will go to the overview page (where all the products are) and will ask the server for the data (makes the data up -to-date again.).
Normally there would be no problem with my app going into background mode. But with the functionality of refreshing the data & going to another controller it probaly gives problems. Therefore I need to be able to close all the UIAlerts still active.
You app crashes not because of UIAlerts but because something is going wrong. Even if you put an app in the background while showing a UIAlert, the alert stays there.
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;
you can use it with this method in AppDelegate.m:
- (void)applicationDidEnterBackground:(UIApplication *)application
but Nikos M. was right: you should find and fix the source of this problem, but not to disguise it. there is a simplest way to show alert, check it, may be it'll help:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Title" message:#"Some message" delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil];
[alertView show];
Related
I have made a custom MessageBox for my application and it launches as a UserControl. I have two buttons inside it and I would like to allow users to press Tab to switch between Buttons. However, since it's a UserControl overlaying the content, Pressing tab more than twice makes the focus go in the background on elements that aren't supposed to be tabbed at.
I can't figure out a good idea how to prevent this, I've thought of making a method that will select all elements and make their IsTabStop values to false and then restore them later, but I think that would be more of a problem then a solution.
Is there a way around this to limit tabbing only to the UserControl?
I would also appreciate advice on working with the message box.. the whole messagebox is an async function that has an infinitive loop until the answer is given. Is there another way to stop the application until one of the message box options was selected?
Crowcoder's reference has lead to correct MSDN page where I found my solution:
dialog = new UCMessageBox("Are you sure you want to exit the application?", MBType.YesNo);
AppMessageBox.Children.Add(dialog);
KeyboardNavigation.SetTabNavigation(dialog, KeyboardNavigationMode.Cycle);
The key was to call .SetTabNavigation function and direct it to my dialog (custom UserControl for the message box) and setting the KeyboardNavigationMode to Cycle.
After closing the UC rest of the application continued normally regarding navigation.
As many people, I tried to look for a solution to customize the onbeforeunload pop up window but I came up with no solution
So I was wondering, is it possible to hide this onbeforeunload (or make it not appear) and make a custom alert/pop up doing the same and customized?
You can't do that, if you add an alert to the onbeforeunload event that will give you a confirm message. if you were to stop that from happening, the page would just close no matter what you put there instead.
all you can do is add a message to the alert which is displayed when asking if you want to stay on the page or leave, even then that is ignored in some browsers.
function promptMessage() {
return "==============================\n\nINFO!!\n\n Please wait on this page until bla bla etc.\n\n==============================";
}
window.onbeforeunload = promptMessage;
The reason you can't and never will be able to do this is because it allows the site owner to stop someone from leaving or bombarding the end user when they try to leave.
Really, its a good thing that this is not allowed.
Myself, I do use onbeforeunload when a user has entered information into a form for example but has not saved that information when they try to leave or click on a link...
Onbeforeunload is a pain in th a** so I can of modify it (just the message) or know when it going to be fired (like clicking a button that goes to other page) and with javascript, disable it ( = null) and make a custom div that was hidden appear to look like a pop up.
In my project i want to show a user-guide when the user first installs my software.So, for only one time i want to show (at beginning) a window where some direction is given so that a user can understand in first time how to use my software.After the user once watches the window(user guide) this window will not appear further time.
I want to use a form like userguid.cs. this will show in the begging of the mainwindow for one time in the life of the my application.
N:B: For example if user restart his computer and again run the app it will not show the userguide window again as it shows before
How can i do that?? Can anyone give idea how can i do that???
Simply maintain a flag, which will help you store, whether the user guide has been displayed or not.
The flag can be a file, which is stored in your application directory, or if you have a database, you can store the boolean value in a db.
Then call the function to display the user guide, when the form loads, or wherever you require.
public void Form1_Load() {
displayUserGuide();
}
And, in the function displayUserGuide see whether flag has been set or not.
public void displayUserGuide() {
//Return, if the form has already been displayed.
if(File.Exists("UGUID")) return;
userGuide.Show();
File.Create("UGUID");
}
You can simply call the functiondisplayUserGuide() any where you want throughout the Application. The function will make sure the form is displayed only once.
In this way you can display Windows form application once.
Hope this helps!
You can create a dummy file in the application path to make sure whether userguide displayed or not.
For Example,
Before loading UserGuide.cs, check for the following,
if(!File.Exists("UserGuideShown"))
{
UserGuide.Show();
File.Create("UserGuideShown");
}
When next time, the application loads, it will check for the file, it will be exists as it shown already. so it will skip showing up..
Please guide me as how to save/discard values of controls of a form, upon pressing Ok/Cancel button accordingly in Visual Studio C#?
Controls in a form include TablelayoutPanel(TextBoxes), NumericUpDown.
Need your expert guidance
Regards
Asad
With both of your buttons, inside the "onclick" event, call a function that will save the content of the form. You also need this call in the "onclose" event of the form, in case the user presses the top-right X button (or not, if you dont want data to be saved at that moment)
Inside that function, you will need some code that will save data to the registry.
Writing in the registry is easy. This webpage also explain how to get the data back. The values you will write will be the textbox.Value and such
The question isn't clear, but in a WinForm you can call
this.Close()
on the Click event of your Close button.
Every object or variable used by the form will be destroyed. Be careful! running background threads will still be alive until they terminate.
About saving the status of your variables it completely depends on what you need to with them after; you can either keep them in memory and pass them around like parameters or write on a disk (maybe with serialization?).
We need to know more.
edit
You may want to take a look at Application Configuration ( http://msdn.microsoft.com/en-us/library/ms184658(VS.80).aspx ).
I've some questions .. and I really need your help.
I have an application.
First I display a splash screen, a form, and this splash would call another form.
Problem: When the splash form is displayed, if I then open another application on the top of the splash, and then minimize this newly opened application window, the splash screen becomes white. How do I avoid this? I want my splash to be displayed clearly and not affected by any application.
I'm using a DropDownList but I realized that there is 2 types of it . I found "Dropdown" which makes the text inside the DDL editable, and "DropDownList" which doesn't.
Problem: when I tried to use DropDownList control it doesn't allow me to add a default text while DropDown does so I want a DropDownList control which prevent modifying on the text and allow a default text .. what property should I use?
Can I add "?" which denotes to Help button to the FormBorder (with the minimization, maximization, and close buttons )
Can I change the colour of the Formborder from its default colour (blue) ?
One of my application functionality is to copy files from server to phone into a certain folder in memory card.
Problem : can I determine the free size of the MMC to notify the user if it's full while copying.
3) You have to set the "HelpButton" property of the form to true. However the "?" button is only visible if you deactivate the maximize and minimize buttons by setting "MinimizeBox" and "MaximizeBox" to false.
Here are a few...
1) you need to launch the window in another thread so that your app can do what it needs to do to start. When the startup finishes, signal to the splash screen that it can close itself.
2)
dropDownList.SelectedIndex = 0;
4) I would not recommend doing so. It is based on the system color scheme, which the user sets. I would not like an app to decide for itself which scheme to use.
5) if the MMC shows up as a mapped drive you could use one of these techniques
Once again there is no answer to this guys question.
Yes, do as the other guy said and launch the splash screen in its own thread.
There is only one type of ComboBox in .Net, However there is a property called DropDownStyle which sets its functionality.
Yes, I am clueless on how this one works and never needed it.
Yes you betcha, Its called non-client painting. you can find more info on it here http://www.codeplex.com/CustomerBorderForm/Wiki/View.aspx?title=Painting%20NonClient%20Area&referringTitle=Home
I Need more details on this.