iOS FBSDKLikeControl / FBSDKLikeButton cached like result? - ios

I found out that the FBSDKLikeControl cached the like result.
When I click the Like control to like a page, I can verify from browser that the page is liked. The FBSDKLikeControl codes are as follow:
if(likeButton) {
[likeButton removeFromSuperview];
likeButton = nil;
}
likeButton = [[FBSDKLikeControl alloc] initWithFrame:CGRectMake(150, 150, 200, 50)];
likeButton.likeControlStyle = FBSDKLikeControlStyleStandard;
likeButton.likeControlHorizontalAlignment = FBSDKLikeControlHorizontalAlignmentCenter;
likeButton.objectID = #"https://www.facebook.com/FacebookDevelopers"; // FBID: 19292868552
likeButton.center = self.view.center;
[self.view addSubview:likeButton];
Then, I unlike the Page in browser and reload the view controller to make sure the like button is recreated, the Like Control still claims I liked the page.
How can I avoid the cache? The same situation happens in FBSDKLikeButton. Using FBSDKShareKit 4.8.0 via Cocoapods

Related

How to implement multiple tabs like in safari?

I am currently creating a google-cast app for iPhone. Its all working like I wanted, I can cast a video on GoogleCast. My only problem is that if the website user visiting has popup ads, the webview automatically redirects to that ad site (sometimes multiple redirects at once).
Since UIWebView doesnt have adBlock function, I thought maybe I should implement multiple tabs feature, so that the ad can be opened in a new tab and the user can close the ad tab manually.
Thanks in advance.
Has any of you have experience with this?
first of you need to use WKWebView instead of UIWebView, now to your point about the tabs, there isnt actually an already made component that will handle this for you but what you can do is intercept the requests from the webview's delegate (WKNavigationDelegate for WKWebView and UIWebViewDelegate for UIWebView) and whenever you feel that a request needs to be open in a separate webview then you block that request in the current webview and create a new view with a new webview nested in it and a close button and whatever else you feel a 'tab' needs to have and execute that request (the one you blocked in the original webview) in there
In decidePolicyForNavigationAction delegate method you can declare a new WKWebView class and add it as a subview to previous WKWebView class based on navigationType or request. For example see below code snippet how am doing and which works fine to me.
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler{
if (navigationAction.navigationType == WKNavigationTypeLinkActivated) { // OR if (![navigationAction.request.URL.Path isEqualToString:#"Previous URL Path"]) {
// Add cancel button at top of new tab
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(5, 5, 50, 20);
[btn setTitle:#"Close" forState:UIControlStateNormal];
btn.backgroundColor = [UIColor redColor];
[btn addTarget:self action:#selector(close:) forControlEvents:UIControlEventTouchUpInside];
CGRect nFrm = oldWebVw.frame; // Set frame as per your requirement.
nFrm.origin.y = 100;
nFrm.size.height -=120;
newWebVw = [[WKWebView alloc] initWithFrame:nFrm];
newWebVw.backgroundColor = [UIColor blueColor];
[newWebVw addSubview:btn];
[oldWebVw addSubview:newWebVw];
[newWebVw loadRequest:navigationAction.request];
decisionHandler(WKNavigationActionPolicyCancel); // You must cancel the policy else the new request loades on previous WKWebView class
return;
}
decisionHandler(WKNavigationActionPolicyAllow);
}
here's an opensource ios browser that supported multiple tabs
Radium Browser

FoxitIOSRDK: not able to click on Hyperlink

I am using FoxitRDK framework for opening the pdf document in my App. In the demo everything works fine apart from one thing: I am not able to click on hyperlink. I have go through the SDK document and the classes inside framework but can not able to fine the solution.
The document link is below:
http://www.foxitsdk.com/docs/mobile-pdf-sdk/developer_guide_ios.pdf
and here is my code
NSString* pdfPath = [[NSBundle mainBundle] pathForResource:#"getting_started_ios1" ofType:#"pdf"];
// Initialize a PDFDoc object with the path to the PDF file
FSPDFDoc* pdfdoc = [FSPDFDoc createFromFilePath:pdfPath];
// Initialize a FSPDFViewCtrl object with the size of the entire screen
pdfViewCtrl = [[FSPDFViewCtrl alloc] initWithFrame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-60)];
[pdfViewCtrl registerDocEventListener:self];
[pdfViewCtrl registerPageEventListener:self];
[pdfViewCtrl registerGestureEventListener:self];
// Set the document to display
[pdfViewCtrl setDoc:pdfdoc];
// Add the pdfViewCtrl to the root view
[self.view addSubview:pdfViewCtrl];
extensionsManager= [[UIExtensionsManager alloc]initWithPDFViewControl:pdfViewCtrl];
pdfViewCtrl.extensionsManager = extensionsManager;
[extensionsManager registerAnnotEventListener:self];
[extensionsManager registerAnnotHandler:self];
//Search button
searchButton = [[UIButton alloc] initWithFrame:CGRectMake(280, 80, 80, 40)];
[searchButton setBackgroundColor:[UIColor grayColor]];
[searchButton setTitle: #"Search" forState: UIControlStateNormal];
[searchButton addTarget:self action:#selector(showSearchBar)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:searchButton];
How can I fix this?
You need to added UI extensions component to your app.
you can refer to the step in section"2.4.5 Add support for Text Search, Bookmark, and Annotation" of the developer guide.
After added the UI extensions to you project, and Initialize it, the link will be work.
related code are here:
"#import "../uiextensions/UIExtensionsManager.h"
UIExtensionsManager* extensionsManager;
...
extensionsManager = [[UIExtensionsManager alloc] initWithPDFViewControl:pdfViewCtrl];
pdfViewCtrl.extensionsManager = extensionsManager;"
If you want to Goto special page when a document open, you need to do it in the onDocOpened event.
(void)onDocOpened:(FSPDFDoc*)document error:(int)error
{
[_pdfViewCtrl gotoPage:2 animated:false];
}
Thanks Foxit support team after updating the version to 2.0 it works perfect.
I have got the solution.
Good luck Team.

Come back to app from an other app

Hello,
When we are phoning with us iphone and you left the call view to come back at springboard, we can come back to the call view with the status bar. (This picture can better explain : http://what-when-how.com/wp-content/uploads/2011/08/tmpB178_thumb.jpg)
Or, in the Facebook app when you go to the messenger Facebook app (not same app) we can touch status bar to comme back Facebook App too.
I would like to know if it's possible to make it in my app ? And if it's possible, how I will proceed ? (Edit: I want co come back in my app from another app such Youtube.)
Thanks
Once you become familiar with how to open another app within your current app form following link:
http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
You can simply create a view that has tap gesture and use it as a button
- (void)viewDidLoad
{
[super viewDidLoad];
[self.navigationController setNavigationBarHidden:YES];
UIView *tapToReturnButton = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)];
tapToReturnButton.backgroundColor = [UIColor blueColor];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self
action:#selector(tapToReturnButtonClicked)];
[tap setNumberOfTouchesRequired:1];
[tapToReturnButton addGestureRecognizer:tap];
UILabel *tapToReturnLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, 20)];
tapToReturnLabel.text = #"Tap to return";
tapToReturnLabel.textColor = [UIColor whiteColor];
tapToReturnLabel.textAlignment = NSTextAlignmentCenter;
tapToReturnLabel.font = [UIFont fontWithName:#"ArialMT"
size:14];
[tapToReturnButton addSubview:tapToReturnLabel];
[self.view addSubview:tapToReturnButton];
}
- (void)tapToReturnButtonClicked
{
NSLog(#"Now you add your code that opens another app(URL) here");
}
Edited:
After I posted the code above I kind of realized that there will be no tap gesture on the status bar even though other bottom part (20 pixel) of tapToReturnButton has a click gesture. After I did some research, I think following link has the better solution on click gesture. I will probably use tapToReturnButton as placeholder to let users know where to touch though and remove UITapGestureRecognizer *tap.
How to detect touches in status bar
Again, I think there is multiple way to achieve your need but those links above will give you good starting point.
URL schemes will allow you to launch an app from an another app.
Check the following links for more info:
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW18
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW50
here are some system supported URL schemes
https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007899

Custom UITable in FBFriendPickerViewController

I would like to know if there is any way to completely replace FBFriendPickerViewController's UITableView or modify the current one.
I need to reverse colors on the table ( white labels, black background) and I wasn't able to do that. So far, I was able to replace table's background but nothing else worked.
I tried something like:
self.myFriendPicker = [[FBFriendPickerViewController alloc] init];
self.myFriendPicker.delegate = self;
[self.myFriendPicker loadData];
[self.myFriendPicker clearSelection];
self.myFriendPicker.allowsMultipleSelection = NO;
self.myFriendPicker.view.frame = CGRectMake(30, 50, 250, 340);
And then I tried to create a new UITableView with red background to try it out and see if it works.
UITableView *tbView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 100, 100) style:UITableViewStylePlain];
tbView.backgroundColor = [UIColor redColor];
self.myFriendPicker.tableView = tbView;
It didn't work and I would appreciate some suggestions.
Thanks for help.
I ended up implementing my own fabecookfriendpicker as a subview of uitableview.Displayinging the list of your friends is not a big issue but even though It is not a straightforward task since you need to lazy load the images and so on.
You have more opportunities to custumize the view with approach.But you can also try subclassing the FBFriendPickerViewController itself

iOS waiting screen

When my app is launched I'd like to display a kind of "waiting view" so I can make the first http calls before accessing to the app.
I saw a nice one, all grey and a little transparent with only an activity indicator inside.
I do not really know how to build this kind of view in a good manner, is it a simple UIView ?
Fist short answer is: yes, the simplest way is to use a UIActivityIndicatorView.
If you don't like all this "big" static libraries just use this:
#import <QuartzCore/QuartzCore.h>
.....
- (UIActivityIndicatorView *)showActivityIndicatorOnView:(UIView*)aView
{
CGSize viewSize = aView.bounds.size;
// create new dialog box view and components
UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
// other size? change it
activityIndicatorView.bounds = CGRectMake(0, 0, 65, 65);
activityIndicatorView.hidesWhenStopped = YES;
activityIndicatorView.alpha = 0.7f;
activityIndicatorView.backgroundColor = [UIColor blackColor];
activityIndicatorView.layer.cornerRadius = 10.0f;
// display it in the center of your view
activityIndicatorView.center = CGPointMake(viewSize.width / 2.0, viewSize.height / 2.0);
[aView addSubview:activityIndicatorView];
[activityIndicatorView startAnimating];
return activityIndicatorView;
}
This needs access to a QuartzCore class so add it in to you frameworks. After you task is done send it a stopAnimating and it will disappear. If you don't need it anymore remove it from your view to save memory (btw. this is ARC code).
I call it like this
self.activityIndicatorView = [self showActivityIndicatorOnView:self.parentViewController.view];
In this case I have UINavigationViewController as a main view controller in my app. This is importent because the activity indicator should show up in the middle of the screen and not e.g. in the middle of a table view.
The simplest implementation is this:
- (UIActivityIndicatorView *)showSimpleActivityIndicatorOnView:(UIView*)aView
{
CGSize viewSize = aView.bounds.size;
// create new dialog box view and components
UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicatorView.center = CGPointMake(viewSize.width / 2.0, viewSize.height / 2.0);
[aView addSubview:activityIndicatorView];
[activityIndicatorView startAnimating];
return activityIndicatorView;
}
MBProgressHUD might be what you're looking for:
https://github.com/matej/MBProgressHUD
There are many many way to do this, but yes, it can be a simple UIView.
Maybe you should give a look at three20 library which offers built-in loaders TTActivityLabel like these:

Resources