I put an in app purchase into my app, and when the user taps a button, the purchase is started. So basically, they tap the button, and then depending on the speed on their Internet connection, they could be waiting for up to ten seconds until a new alert view comes up asking if they would like to buy the product. The user will probably tap the button multiple times since nothing came up, and then multiple purchase alert views will come up. Additionally, this could maybe be seen by the user as an app bug. In the end, this is a problem.
I want an alert view to come up with a spinning wheel that says "Loading..." when the users taps the buy button. Now my problem is, how do I get that to dismiss when the new alert view comes up asking the user if they want to buy the product?
if ([UIAlertView alloc] that says: #"whatever Apple's alert view says")
{
//dismiss the "Loading..." alert view here
}
I doubt that would work, so any input is appreciated. Thanks!
You need to have access to that alertview. You can do this. Create a alertview instance var in app delegate and when you want to show loading initialize that instance var assign to your property and when you want to dismiss just call
[alertViewinstance dismissWithClickedButtonAtIndex:0];
Write this piece of code in a method in appDelegate. Hope you get the idea. If not let me know I'll post the sample code here.
Related
I know its interesting title for my question. Sorry for that. Here is my problem;
I am doing simple login screen (with facebook frameworks). If user wants to login with his/her facebook account, firstly he/she must confirm facebook page. And then i get their email addres, name, surname..etc information of user.
After that i just ask them password for my app. This password screen is a view. and opening on main view(not as new viewcontroller. its view on main view) And after confirm facebook page then this wiew appear.
On this password view has 2 textbox and 2 button. textbox for paswword(and confirmation) and First button send request to my web service with user information. and other button is "cancel" button.
here is the problem. When user send request i create nsnotification for waiting respond. after getting respond. i want to this password view get hide.
here is the code:
#IBAction func buttonSave(sender: AnyObject) {
var myObj = connectObject()
myObj.sendRequest("http://localhost:8888/iphone/hearMe/index.php", param: "id=test123")
NSNotificationCenter.defaultCenter().addObserver(self, selector: "actOnSpecialNotification", name: "sendDataCheck", object: nil)
}
func actOnSpecialNotification() {
println("ok I got success respond from webservice")
self.viewPassword.hidden = true /*This is my view */
}
with this code. "viewPassword" view hided but not instantly. It hide after 10 or 15 seconds. How i can hide that view instantly after getting response from webservice?
It's not clear from your question whether the 10-15 seconds is between the pushing of the button and the hiding of the view, or between the printing of "ok I got…" and the hiding of the view.
If the lag is between pushing the button and calling actOnSpecialNotification(), then the above code doesn't help us. We need to know what object posts the notification sendDataCheck and why it takes so long. Maybe it just takes that long to talk to the network. Maybe it posts the notification before you start observing it. You probably want to call addObserver() before sending the request rather than after (just in case there's an async operation in there).
If the lag is between printing the "ok I go…" line and hiding the view, then the most common cause of that is that the notification was posted on a background queue. You can't interact with UIKit anywhere but the main queue, and weird lags are a common symptom when you do.
(Side note: when in doubt, use let, not var. myObj is better defined let here. This helps protect against many kinds of bugs.)
I am working on Map View project but when my app loads up i get this alert on the very first screen
'"Project Name Would Like to Use Your Current Location"(Alert Message) "Don't Allow"(button) "OK"(button)'(Location Alert Box)
before the Map View it shows me alert on the first view i want when i switch to Map View then only the alert should come up so that at that time user can click "OK" and App will be able to use the location of user, i have searched alot but did not found some good ways to do it, i know it can be done because i have seen one or two app doing that thing but i am not able to do this feature in my app ... plz help me out in this...
I just want that the alert of location search should only show up when i reach on map view screen of my application not before that .. any suggestions ?? coding will be much appreciated.
You can simply not instantiate your CLLocationManager until you reach the screen where you want the alert to appear. It is the instantiation of the location manager that is prompting the OS to display the alert.
As GeraldWilliam already explained, its the CLLocationManager that forces the popup, which you cannot alter.
However, what you could do is show the mapview and ask the user for its current location when the view is loaded, e.g. using the – viewDidAppear: method.
my app is almost finished and since is for airline pilots I would like to add a disclamer (like an alert view...but more like a scroll view) that pop up as soon as they start the app and if they don't press ok I want to exit from the app. Any advice would be really appreciated.
thanks
Just use a UIAlertView — if you put a lot of text in it, it automatically scrolls.
If the user presses the "No" button, you need to just disable the app rather than exit — apps aren't allowed to exit unless the user presses the home button. You could pop up a modal view controller (with no way of dismissing it) with a message saying that the app cannot be used until the disclaimer is read and accepted.
Could anyone please tell me how to handle push notification dialog's view and close button click from my application? I have gone through this thread which says to handle it in ViewDidLoad but when I click View button, this method doesn't get invoked. I want to do take user to some particular view on View button click and record the Close button click on my Server. So basically I want to know what happens when this button(s) clicked? I have gone through Apple docs but it nothing say about these actions. Any documentation and/or code sample would be really greatful.
Thanks.
If user clicks view then you can catch that action in didFinishLaunchWithOptions method of AppDelegate class. If user clicks close then, there is no way for application to catch that. If your application didn't get the notification in AppDelegate class, then either you forgot to register your app for push notification or you didn't send push notification properly to APNS.
If an app delegate receives the -willResignActive message and a UIAlertView is within 0.5 seconds of being shown, the app will present two alert views (one a duplicate) when it becomes active once more.
This is a problem, because if responding to the first alert view means there are no responders to the duplicate (likely!) the app will just crash.
Thoughts?
The best solution I have is to retain a static reference to a UIAlertView, dismiss (with clicked button index -1), release, and then allocate/init a new instance at the same address. This makes sure there's only ever one alert view scheduled or showing. If an alert view is already showing, ignore (or manage) the new request (failsafe popping to root view or some such).
It's not very satisfactory because UIAlertViews have nothing to do with the workings and shouldn't be static. In my mind at least.