In UIWebView how integrate "Add bookmark " feature - objective-c

I want to integrate add book mark like safari in iphone like
here the snapshot of add bookmark feature of safari browser from iPhone i want to add same feature like it
How can i do it ?

http://xcode4all.wordpress.com/2011/05/25/web-browser-or-how-to-use-the-uiwebview-part-33/
It will be helpful

First you will need to add an alertView
sheet = [[UIActionSheet alloc] initWithTitle:#"Select Account to Delete"
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:#"Delete All Accounts"
otherButtonTitles:#"Add bookmark", #"add to reading", #"add to home screen", nil];
// Show the sheet
[sheet showInView:self.view];
[sheet release];
that will create a popup view (AKA alertview) as your image shows above.
as for the "Add bookmark" or "add to home" it is slightly more complex, since the API does not provide you with the functions to do so, your best bet will be looking at a webview programatically launch Safari from within your app and give it the URL
read about it here: iPhone SDK - Add a "Add to Home Screen" button in a UIWebView

Related

how to display a multiple choice picker

i'm trying to find the correct control to display a choice selector, like the one which appears in Safari when you long press on image.
It should be some kind of UIPickerView, but it is not the same design.
Any idea is welcome.
This looks like UIActionSheet, which can be presented for example from the UITabBarController likes this:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#"This will delete all your records. Are you sure you want to continue?" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:#"Yes, go ahead." otherButtonTitles: nil];
[actionSheet showFromTabBar:self.tabBarController.tabBar];

iOS strange bug with button and view change

That's the first time i post on this site.
I explain, i have to work on an already advanced project in ios.
I'm new in objective-c and it's a quite strange language when you come from java.
I have a strange issue.
In the app there is a login screen, you put mail and pass, click on a button and you go on the main view. It's work perfectly.
What i want to do is autologin. I use keychains for that, store it, retrieve it, populate my user and pass with. It's works perfectly.
If my user click on the login button it's also work perfectly.
But if i call the function myself with the code, it doesn't change the view. I can't understand why.
I put here the code where i think the change is called.
if ([result isEqualToString:#"1"]) {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:Email.text forKey:#"email"];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Welcom back to FriendsCam!" message:#"Start sharing your video" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
//Email.text = nil;
//Password.text = nil;
UIStoryboard *MainStoryboard_iPhone=[UIStoryboard storyboardWithName:#"MainStoryboard_iPhone" bundle:nil];
self.view.window.rootViewController=[MainStoryboard_iPhone instantiateInitialViewController];
So this code is in a function who is called by the functions called when the button login is pressed if all field are correctly fill.
It work when a user manually click on the button but not when i call the button's function myself in code but the alert "welcome back" of good login show in both cases. it's only the jump in the storyboard who is broken.
Can someone explain why ? It will be very kind.
Ok i find the solution.
I was firing my method to quickly, something related with loading time of the view i think.
I delay my call with a nstimer and all work perfectly.

Why is my UIActionSheet hidden by my TabBarController?

I am having a problem correctly implementing a UIActionSheet in an iPad 5.1 (XCode 4.3) project. I can populate it correctly with all the items I need. The list is longer than the window, but the scrollbars automatically come up, etc. However, the cancel button (which I presume is supposed to be at the end) is coming up half hidden behind my tab bar. Shown below:
(sorry, SO won't let me post images yet)
Here is my storyboard setup:
The entry point is that Tab Bar Controller on the left, which goes to another Navigation Controller (center), which has the View Controller on the right as the root view.
http://i854.photobucket.com/albums/ab103/srVincentVega/ScreenShot2012-06-28at52713PM.png
I have tried presenting the UIActionSheet in all sorts of ways, but this odd behavior persists, and I can't figure out how to address it
- (IBAction)cmdReason:(id)sender
{
NSArray *reasons = [AppState getInspReasons];
UIActionSheet *action = [[UIActionSheet alloc]
initWithTitle:#"Reason for Inspection"
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:nil];
for (NSString *rsn in reasons)
{
[action addButtonWithTitle:rsn];
}
[action showInView:self.view];
}
I have tried the various methods to show "action" - showFromTabBar, showFromToolbar, etc - I am VERY new to this development environment, so I am not up to speed yet on how these items interact at this level. Does anyone have a suggestion for how I can present this correctly?
I am sorry if this has already been asked elsewhere. I have spent all day trying bits of code from all over the web, including SO. I don't know if it's something to do with my storyboard layout, or what.
One further thing - when I rotate the emulator, the action sheet does redraw, but the bit at the end there gets wonky looking, like it can no longer figure out how to draw it.
Many thanks!
EDIT:
I have put together a very small project that demonstrates this exact behavior. I don't have a good way to host the zip file, so I put on google docs and shared it. The link is below. If you click on that, there should be a download option under file that will give you the original zip file.
https://docs.google.com/open?id=0B7IYvy9_c_NLaEFneGc5bzc2S2c
Seems like there is not a real solution for this. It looks like it's a limitation with UIActionSheet if you add that amount of button titles and present that from a tab bar.
Beside that, the proper way to display an UIActionSheet from a tab bar is to use
[action showFromTabBar:self.tabBarController.tabBar];
instead of
// Taken from your example project
AppDelegate *d = [[UIApplication sharedApplication] delegate];
UIWindow *w = d.window;
UIViewController *vc = w.rootViewController;
UITabBarController *c = (UITabBarController *)vc;
UITabBar *t = c.tabBar;
[action showFromTabBar:t];
I would think if you got a reference to the tab bar controller then you should be able to present it from that. You can try showing it from the main window but I would think you shouldn't rely on that.
[action showInView:[[UIApplication sharedApplication] keyWindow]];
Try this:
CGRect r = CGRectMake(x, y, w, h); //change values to fit location of button
[actionSheet showFromRect:r inView:self.view animated:YES];
I used it on one of my apps with the same problem and the dismiss button showed up ok.

UIDocumentInteractionController: "Open In" visible on iPhone but not on iPad - why?

For testing purposes I wrote two apps:
First one plays an MP3 file using UIDocumentInteractionController
Second one does nothing but registers for the file type "public.mp3"
If I deploy the apps to the iPhone Simulator, my MP3 player app shows a button on top "Open in 'MP3Test'". If I deploy to the iPad Simulator however, there is no button and no "Open In" menu either.
This has been tested with iOS5.
Can somebody explain if this is a bug or a feature and what the reason is behind it?
Depends upon where you are presenting it from.
If you are presenting it from somewhere around the middle of the screen or below, just present from the frame of the object that you are presenting from.
if that is on the navigation bar, try this:
NSString *fileToOpen = [[NSBundle mainBundle] pathForResource:#"License" ofType:#"pdf"];
UIDocumentInteractionController *controller = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:fileToOpen]];
controller.delegate = self;
CGRect navRect = self.navigationController.navigationBar.frame;
navRect.size = CGSizeMake(1500.0f, 40.0f);
[controller presentOptionsMenuFromRect:navRect inView:self.view animated:YES];
The iPad has an affinity for popovers (see UIPopover), why it presents UIActionSheets in them. Facing a similar issue that you had, I had my UIDocumentInteractionController present itself from an UIBarButtonItem (resulting in a UIPopover presentation), rather than from the view itself (something that worked just fine on the iPhone):
Save a reference to the action button (I have mine in my navigation bar).
Use PresentOpenInMenu using the action button reference, rather than the View reference, resulting in a UIPopover-presentation.
Please note that the change does not effect the iPhone app - it behaves likes before, i.e. opens the OpenInMenu from the bottom of the screen just as it would, if you'd used the View reference to present it.
On iPad UIDocumentInteractionController appearing like Pop Up Try something like this
-(void)shareClick:(UIButton*)sender {
/*some code*/
CGRect rectFor appearing = [sender.superview convertRect:sender.frame toView:self.view];
[interactionController presentOptionsMenuFromRect:rect inView:self.view animated:YES];
}

Strange behavior of Cancel button's ActionSheet

I'm new in Objective-C, I try to code an iPad App (Objective-C 2.0, Xcode 4.0.1).
I "play" with ActionSheet to understand how it works. In a nib file I put a button binded to my "buttonPressed" method.
I've written this code :
-(IBAction)buttonPressed
{
UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:#"My Action Sheet" delegate:nil cancelButtonTitle:#"Cancel" destructiveButtonTitle:#"OK" otherButtonTitles:#"Test", nil];
NSLog([NSString stringWithFormat:#"%d", [myActionSheet numberOfButtons]]);
NSLog([myActionSheet buttonTitleAtIndex:0]);
NSLog([myActionSheet buttonTitleAtIndex:1]);
NSLog([myActionSheet buttonTitleAtIndex:2]);
[myActionSheet showInView:self.view];
[myActionSheet release];
}
This is the NSLog result :
2011-04-14 14:52:30.428 TrampManage[3568:207] 3
2011-04-14 14:52:30.429 TrampManage[3568:207] OK
2011-04-14 14:52:30.430 TrampManage[3568:207] Test
2011-04-14 14:52:30.432 TrampManage[3568:207] Cancel
But the displayed view is quiet different (cf image : http://www.imagup.com/data/1117452257.html). For the moment, I've one simple question : Why my "Cancel" button doesn't appear ?
As your tag hints, you are probably working on an ipad project.
The documentation says about the cancel button for iPads:
cancelButtonTitle The title of the
cancel button. This button is added to
the action sheet automatically and
assigned an appropriate index, which
is available from the
cancelButtonIndex property. This
button is displayed in black to
indicate that it represents the cancel
action. Specify nil if you do not want
a cancel button or are presenting the
action sheet on an iPad.
You can cancel by touching outside the action sheet.
You're most likely on an iPad, where the new interface idiom is to not show the cancel button. A user can cancel the sheet by simply clicking outside the sheet. Not the best design decision IMHO, but that's the way it is now.
on ipad it doesn't shows the cancel button. because ipad has more width than the iphone & for dismiss it you can tab outside the actionsheet on ipad.
Detail explaination:
see this image of iphone which shows ok button
below Figure shows the action sheet when displayed on the iPad.
Interestingly, on the iPad the OK button (set by the
cancelButtonTitle: parameter) is not displayed.
The value (buttonIndex) of each button when clicked is as follows: ➤
Delete Message — 0 ➤ Option 1 — 1 ➤ Option 2 — 2 ➤ OK
— 3 On the iPad, when the user taps on an area outside of the
action sheet, the action sheet is dismissed and the value of
buttonIndex becomes 3. Interestingly, if you specified nil for the
cancelButtonTitle: part, the value of buttonIndex would be –1 when the
action sheet is dismissed.