I have an iPhone application that I use the ABPersonViewController and I allow delete.
The thing is that the application is a TabBar application and when i use the regular delete method I get this warning:
Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:].
the problem is that when I try to press on the "Cancel" of the delete, it does not work!
I want the action sheet to pop up from the TabBar, How do I do that?
this is the code:
if ([personController respondsToSelector:#selector(setAllowsDeletion:)])
[personController setAllowsDeletion:YES]; //CAN CAUSE THE APPLICATION TO BE DENIED FROM THE APP-STORE
To display an action sheet from a tab bar, you can call the following within the view controller that is presenting it: [actionSheet showFromTabBar:self.tabBarController.tabBar];
This answer is explained in this post.
Related
I have a UIActionSheet that displays various buttons, one of which posts a tweet to Twitter. To do so, the app has to request permission to access the user's Twitter account that they set in the settings on iOS 5. The problem is this popup gets hidden behind the UIActionSheet, like so:
screenshot http://dl.dropbox.com/u/51070/actionsheet.png
How can I get it to show above the action sheet? I've also tried dismissing the action sheet through dismissWithClickedButtonIndex:animated before calling the tweet function, but this problem still occurred.
Thanks!
Try calling your tweet method like this:
[self performSelector:#selector(myTweetMethod) withObject:nil afterDelay:0.1];
This should give the action sheet enough time to dismiss before invoking the tweet code.
If I get an alert in my application and if I put application in background and press application icon to enter the application, a splash screen is displayed and then the alert pop up. Why splash screen appears?
And if alert is not present and I put application in background and press application icon to enter the application, splash screen is not displayed.
First you have to make the UIAlertView a property in your class.
In your AppDelegate Class you can implement the applicationDidEnterBackground: Method in wich you can put something like this:
[yourViewController.yourAlert dismissWithClickedButtonIndex:0 animated:NO];
This should dismiss the alert if your app enters the background.
Hope this helps!
The splash screen is as #akshay1188 mentions, is the Default.png in your project file. The reason for it being displayed, based on my best assumption, is because the OS has not managed to take a screenshot of your App before you go back to it. See this answer to a StackOverflow question where it was discussed.
As for the UIAlertView, #pKoul's anwser got my upvote.
Maybe you can use the notification posted UIApplicationDidEnterBackgroundNotification in any class that needs some cleanup before entering bg. Do not forget to remove the observer in dealloc.
[[NSNotificationCenter defaultCenter] addObserver: self
selector: #selector(cleanup:)
name: UIApplicationDidEnterBackgroundNotification
object: nil]
The splash screen is actually the launch image that you might be using as Default.png
If you want to dismiss all AlertViews programmatically you have to Remember a Reference to the currently shown Alterviews. I recommend a Singleton class where you ask for an AlertView and wich saves a Reference to the AlertView.
then you could use the
`- (void)applicationDidEnterBackground:(UIApplication *)application`
in your AppDelegate and call a Function on the Singleton Class, wich itself calls
[alert dismissWithClickedButtonIndex:0 animated:YES];
at all Alertviews.
In my Universal App I have a long UITableView with custom cells..and for some cells I may need to show some long pop-up explanaiton about that cell when for instance user clicks a "i" label on the cell. In iPad popover view seems excellent choice for this, but don't know how can I implement this on iPhone, what are the possibilities? Also I want to spend as less time as possible when making it work for iPad- popover view. I want to re-use some of the code or logic i use on iPhone
Things came up to my mind;
-Show explaination in alert shild, but the current look and feel of alert shield is ugly can I customize it however I like and show wherever I line on screen and if I can make it scrollable;
-Or maybe I can make a uitextview to show on top, but then how will I dismiss it, I will need some buttons there..which sounds tricky.
-UIActionsheet with a uitextview on it, is reasonable here?
Also I found this code in S.O but dont know how to use this in my case;
newView.frame = CGRectMake(60, 140, 200, 200);
[parentView addSubview:newView];
Have a look at http://iosdevelopertips.com/open-source/ios-open-source-popover-api-for-iphone-wepopover.html. It's a Popover component for iPhone. I think it works best in your case. You can Google "iphone popover" for more options.
We built an open source library for iPad-like popovers on iPhone allowing you to customise the look and feel of the popovers and place any view or controller inside it.
Watch the project on Github and download it at http://www.50pixels.com/blog/labs/open-library-fppopover-ipad-like-popovers-for-iphone/
On dismissing it, see the following instructions:
Know when a new popover is displayed
- (void)presentedNewPopoverController:(FPPopoverController *)newPopoverController
shouldDismissVisiblePopover:(FPPopoverController*)visiblePopoverController;
Use this delegate method to know when a new different popover is displayed. If you want to dismiss the old popover, and release it, send the dismiss message inside this method.
- (void)presentedNewPopoverController:(FPPopoverController *)newPopoverController
shouldDismissVisiblePopover:(FPPopoverController*)visiblePopoverController
{
[visiblePopoverController dismissPopoverAnimated:YES];
[visiblePopoverController autorelease];
}
Know when the popover is dismissed
- (void)popoverControllerDidDismissPopover:(FPPopoverController *)popoverController;
Use this delegate method to know when the popover is dismissed. This could happen when the user taps outside the popover or when a dismiss message is sent by other actions.
Typically if you used a UIPopover on the iPad you use present a Modal view controller on the iPhone.
So if you create a subclass of UIViewController (e.g. called MyViewController), with the necessary subviews such as a UILabel.
MyViewController *infoViewController = [[MyViewController alloc] init];
//pass data to the new view controller, e.g.
//[infoViewController setInfoText:...];
[self presentModalViewController:infoViewController animated:YES];
[infoViewController release];
I am designing a webView with a close button. When the application is launched, it opens the given url. When the button is touched, i want to close the webView.
I need some button event which closes the webView. Thank you for your answers.
UIWebView inherits from UIView. So the answer is: It depends!
If you're using a UINavigationController and used
[[self navigationController] pushViewController:newUIWebController];
you can close your UIView by using
[self.navigationController popViewControllerAnimated:YES];
If you're using some other method to display your view (like addSubView) you can utilize the corresponding method like removeFromSuperview.
Is there a way to call an ActionSheet directly from a tabbar. I'm working on a program where the user wants a contact button on the tab bar that displays an actionsheet with the appropriate buttons.
Thanks in advance
Couldn't you just have a view controller associated with one of the tabs, and then leave its view plain, and in viewDidLoad make the actionSheet?
I agree with all the people above saying that this isn't a good idea (and that this should be done using a toolbar), but it's definitely doable.
The code below implements one of the UITabBarControllerDelegate methods, and avoids the selection of the tab bar item, and instead creates and displays a UIActionSheet:
- (BOOL)tabBarController:(UITabBarController *)tabBarController
shouldSelectViewController:(UIViewController *)viewController
{
NSInteger choice = 0; // --> index of the view controller that should "act as button"
if (viewController == [tabBarController.viewControllers objectAtIndex:choice])
{
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:#"Send e-mail", #"Twitter", #"Whatever", nil];
[sheet showFromTabBar:tabBarController.tabBar];
return NO;
}
return YES;
}
An example would be the mail app were your viewing an email and you hit curved arrow button to bring up the "forward - reply" action sheet.
I think I can understand what Steve's after. I have a main activity reached via the 1st element in the TabBarController. I'd like the 2nd tab-bar element to selectively add either a modalview email, an access to facebook, or an access to twitter. It would be nice if that choice is offered via an actionsheet so as to not lose sight of what's "behind" from that first view controller (from the first tab-bar choice) and THEN the new view controller handling the choice shows up. This seems to be what "AP mobile" does when you want to 'share' a news article, for example.
#Adrian : I couldn't get your solution to work out-of-the-box.. but then found out why (read on...)
It doesn't help (obviously) to specifically drag from the Outlet:delegate to file-owner
You'll get:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Changing the delegate of a tab bar managed by a tab bar controller is not allowed.'
My delegate method was being ignored until I added the UITabBarControllerDelegate to the interface definition (UIApplicationDelegate was already present and I didn't read further)...
AND
In applicationDidFinishLaunching I added
[rootController setDelegate:self];
Cheers.