A Label in View with UIWebView - iphone

I have a View, i would like to put a test ( a UILabel) witch when clicking it, it open me a web View with an URL ( WWW.mySite.com).
How i can do this please ?
thanks for your answers

Use a button, put the text into the button, hook up the actions from the button pressedUpInside to a function which will call the UIWebView's - (void)loadRequest:(NSURLRequest *)request with your URL.

Look up Apple documentation on UIWebView and use a UIButton connected to an IBAction. Always turn to the documentation when these kinds of questions come up. It is really through and usually pretty well done.

Related

Custom popups in iOS using storyboard views or separate nibs

What is the most correct/efficient/up-to-date way to present a popup window in iOS?
A la TweetBot:
Methods I've used:
Presented a popup from a separate nib and used loadNibNamed
Presented a popup from the main storyboard with instantiateViewControllerWithIdentifier
Created/Presented a popup purely programmatically*
*I'd rather not use this method because my popup has a fairly complicated custom UI
Also once I get the scene loaded from any of the methods above I don't know how to connect the UI elements in the popup with outlets/actions (Protocols? Delegates?)
If you could point me in the right direction for the most correct way of creating/showing/using a popup that would be fantastic.
Let me know if i'm being too vague, I can add more detail.
EDITED:
Hm, Just saw your screenshot after entering my answer. Well to do that, you can use a the feature provided by UIAlertView. I am pretty sure that is how the TweetBot guys do it as well. This link here shows a blog article that will let you do what you need.
Unless you want to go crazy custom, there are couple of solution out there that let you accomplish it. Something like this
DONE EDIT
One thing you can use is the Segues. Assuming you are using StoryBoard and when you tap on a button and that brings in a pop up view, you can connect them through something like this:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([[segue identifier] isEqualToString:#"ViewToBringIn"]) {
ViewController *vc = [segue destinationViewController];
vc.navigationItem.title = #"some title";
}
}
Another way of using Segues could be through the StoryBoard UI. Click on the view you want, and that will bring up something like the screenshot in the Connection Inspector:
However, if you are using a nib file, then you can still create them and push them into the view (according to the format you want) via code. Of course the design on the view is done through the Interface Builder.

UIWebView to View Controller?

I was wondering if anyone knew if this was possible?
I have a uiwebview as the first view controller which is showing a basic html page I made with the Facebook login screen. Can you login (in the uiwebview) and once it authorises you (in the uiwebview) it closes and launches the second view controller?
Does anyone know of a good example or tutorial for this?
If not can someone point me in the direction of a good FacebookSDK example or tutorial in Storyboard not XIB?
Thanks!
You should be using the FBLoginView and FBSession classes of the Facebook SDK to log in. You can just use the delegate callbacks from those to drive your next view controller.
I can't think of a reason you would want to bring up the facebook login page in a UIWebView , rather than doing the above. If for some reason you actually need to use a UIWebView , the webViewDidFinishLoad: method of UIWebViewDelegate might provide you with the hook you need.
Download the Facebook sdk from github and check the SessionLoginSample in samples. I think it has everything you need

Close tableview in ViewBasedApplication

probably a very simple question but can't find the right answer anywhere. I am using XCode 4 and working on an iphone app, which probably sums up all the info that I need to provide.
Here it is:
- I created a ViewBasedApplication
- At some point depending on the user input, I load a TableView
But now how on Earth do I add a button or something to return? Note: I can't use a NavigationBased app, that would be easier but would not work for me.
Help anyone?
If you used a UITableViewController, you may want to use a UIViewController instead. In the UIVeiwController, you can add a UITableView along with your own UINavigationBar or, if you don't want to use a UINavigationBar, you could leave room for some type of custom UIButton. Either the UINavigationBar button or your custom UIButton action could trigger a close of your UIViewController.
If you add the UIViewController as a subview, then Cyprian's [self removeFromSuperView]; would work. If you present as a modal as Jamie suggests, you could use [self dismissModalViewControllerAnimated:YES];.
Well I don't know you code but you could always call
[self removeFromSuperView];

UIWebView/MPMoviePlayerController and the "Done" button

I am using the UIWebView to load both streaming audio and video. I have properly set up the UIWebView delegate and I am receiving webViewDidStartLoading and webViewFinishedLoading events perfectly. The webview launches a full screen window (likely a MPMoviePlayerController)
Apple's MoviePlayer example gets the array of Windows to determine which window the moviePlayerWindow is for adding custom drawing/getting at the GUI components. I believe this to be a bad practice/hack.
My expectation is that I should be able to figure out when that button was clicked by either a delegate method or an NSNotification. It may also be the case that I have to poke around subviews or controllers with isKindOf calls, but I don't think those are correct approaches.
Are my expectations incorrect, and if so, why?
What is the correct way to bind an action to that "Done" button?
There isn't an MPMoviePlayer instance method that covers this. You can use - (void) moviePlayBackDidFinish:(NSNotification*)notification to find out when the movie has finished. Or you could overlay the existing Done button with your own and have complete control that way.
You can also use MPMoviePlayerWillExitFullscreenNotification in order to conrol the action provided that youe MoviePlayer is in fulscreen mode.

How to open any link from a UIWebView to a new UIWebView?

I want to make a simple app, where a UIWebView with custom content will have several links to other pages with similar content as well (and a navigation bar on top, with just a back button).
I read the answers to this question, however I'm not sure if I should do that in my application, as the user might be able to go deep enough, and I will be creating new webviews all the time.
What could be the best practice for such a behavior?
Thank you!
I'd recommend listening for:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
and always returning YES (so the webView will continue with the requested link) while storing each request in an NSMutableArray to create a stack of the user's browsing history.
That would let you update a back button's text with the previous page's title (shortened of course).
If you just need to have a back button without label, you could have a simple button hooked up to the UIWebView's - (void) goBack; method.