Is it possible to switch a view without a button? - iphone

I got only so far to be able to switch a view by pressing a button or with a timer. But I don't get it to switch a view by events like didReceiveLocalNotification. Is it impossible to do this?

Yes, that's possible , Because usually we specify the method with notification in which we wish to receive it.
Put the same code from your UIButton action: to notification method.

Yes, all you have to do is doing the switch inside the method didReceiveLocalNotification.
You will need to send a message to the view controller you want to perform the switch.

Related

Timer: See an alert on another view controller when time is up

In my timer application,
My timer runs on oneViewController.
When I switch to another view without any efforts it runs in background of another view
as I press the back button I can see the results..
But,
I want to put an alert message on second view controllerwhen my time is Up.....
How could I do this...
**Should I use
-Delegate
-Notification
-Local Notifications**
Or else.....Thanks
EDIT: Answer:
Answer is in first comment...**
You can make your timer call a method on your view controller. Inside that method, you can check whether time is up. If so, create an UIAlertView instance and -show; it as it will be shown/seen from any view controller.

How to control UIMenuController, in case I do not want it hide automatically?

I'm doing a chat tool, with a UITextField as input. The problem is, when other UI control updates, like messages scroll on new arrivals, the UIMenuController, if currently visible, automatically hides. How can I forbid such automation?
Even I can catch the event with UIMenuControllerWillHideMenuNotification or UIMenuControllerDidHideMenuNotification, there's no way I can control it.
Did u try its instance method
setMenuVisible:(BOOL)menuVisible animated:(BOOL)animated

How to pass textfield values from one view to another view

would you tell me,, what steps i have to add in applications to move values from a view to another when press a button
You can use The NSNotificationCenter which implements the Observer pattern. You have one view that listens for an event and the other view notifies any listeners when the event is triggered, in your case the button pressed.
This SO response has good information on it.
What is NSNotification?
In addition to notifications and delegates, you can always do the quick and dirty method of passing a self class reference forward from one view to the next, and use the previous view class reference in your current view. Please see my blog post about this:
http://www.dosomethinghere.com/2009/10/04/passing-values-and-messages-between-views-on-iphone/

UIAlertViewDelegate clickedButtonAtIndex: usefulness?

The UIAlertViewDelegate protocol defines two methods, alertView:clickedButtonAtIndex: and alertView:didDismissWithButtonIndex:, which seem to me to be identical in usefulness.
Why is there a clickedButtonAtIndex and a didDismissButtonWithIndex when they both do the same thing? I realize there is also a willDismissButtonWithIndex that happens before the alert view is dismissed, but is there any reason to use clickedButtonAtIndex instead of didDismissButtonWithIndex?
I found a more useful difference between the two:
When showing a UIAlertView, and the device goes to sleep, alertView:didDismissWithButtonAtIndex: gets called, even though the alert view is not actually dismissed. It is shown again once the device wakes up. alertView:clickedButtonAtIndex: is only called when the user clicks one of the buttons.
The alertView:clickedButtonAtIndex: is called when the user clicks a button on an alert view whereas the alertView:didDismissWithButtonIndex: is called after an alert view is dismissed from the screen. (See the UIAlertViewDelegate Protocol Reference.)
The difference is minimal but it allows you to do something before or after animation.
If the alert view disappears for any reason (including being covered by another UIAlertView, going to sleep, etc.), didDismissWithButtonAtIndex: is called. This can mean that the method can be called even without the user clicking on anything. This can lead to unexpected behaviour if you depend on this delegate callback to be called in response to the user actually clicking on a button. In this case clickedButtonAtIndex: is more useful.
I couldn't reproduce Ed's behaviour by locking my device with the alert view present on iOS 7.
However, the most important difference between alertView:clickedButtonAtIndex:, alertView:didDismissWithButtonIndex: and alertView:willDismissWithButtonIndex: is that the first method (clickedButtonAtIndex:) is only called when the user explicitly taps on a button on your alert view (hence 'clicked').
Is it possible that an alert view is dismissed without clicking on a button? Yes, you could programmatically hide an alert view using the UIAlertView method dismissWithClickedButtonIndex:animated:.
So, if you need some behavior to be always triggered upon the dismissal of the alert view—whether it was triggered by the user tapping on a button or triggered programmatically—then using the didDismissWithButtonIndex: and willDismissWithButtonIndex: makes more sense.

Call an onclick method from one view to another iphoneprogess hub iphone sdk

I have a view with a button which downloads files when clicked.
Question I have is is it possible to call that click method from another view>
THanks
You have a method there. Something like onBtnClk. You can create in another view an instance of your viewController, that contains this method and send [myViewController onBtnClk].
This may be a good case to have some other class(maybe a singleton?) handle downloads, then have your click: method interact with the downloading class.
I know that everyone hates singletons, but this may be a good time to use one.