I am using fbConnect in my Cocoa Touch application. I have UIWebview on my view, and I want to publish the UIWebview's context (its only text) to FaceBook.
How should I change the FBStream to publish my UIWebview?
FBStreamDialog* dialog2 = [[[FBStreamDialog alloc] init] autorelease];
dialog2.delegate = self;
dialog2.userMessagePrompt = #"Share Ghazals on your wall";
dialog2.attachment = #"{\"name\":\"Hafez Application for iPhone\","
"\"href\":\"http://itunes.apple.com/us/app/divan-of-hafez/id340865571?mt=8?tab=iphone\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"http://photos-h.ak.fbcdn.net/photos-ak-sf2p/v43/67/279420942343/app_5_279420942343_8373.gif\","
"\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],"
"\"properties\":{\"another link\":{\"text\":\"Hafez App HomePage\",\"href\":\"http://www.momeks.com/hafez\"}}}";
// replace this with a friend's UID
// dialog.targetId = #"999999";
[dialog2 show];
Here is my UIWebView Code:
NSString *path = [[NSBundle mainBundle] pathForResource:#"webViewContent" ofType:#"html"];
NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];
NSString *htmlString = [[NSString alloc] initWithData:
[readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];
webView.opaque = NO;
webView.backgroundColor = [UIColor clearColor];
[self.webView loadHTMLString:htmlString baseURL:nil];
[htmlString release];
Not sure I understand what you mean by sharing UIWebview context.
If you want to publish text, then there are numerous examples for that on FBConnect.
You might want to try ShareKit, as it makes everything very easy....
If you could please re-explain the question, I could offer better help.
Godspeed,
Oded.
Related
In my new iOS Project I'd like the end user to be able to MMS text and/or images(from TextField) in a UIButton Action . I've seen similar apps that has this functionality (with text, haven't seen one with images yet).
I have search in google but could not find how to do this, any help much appreciated
This will work fine
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.persistent = YES;
pasteboard.image = [UIImage imageNamed:#"PDF_File.png"];
NSString *phoneToCall = #"sms:";
NSString *phoneToCallEncoded = [phoneToCall stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [[NSURL alloc] initWithString:phoneToCallEncoded];
[[UIApplication sharedApplication] openURL:url];
if([MFMessageComposeViewController canSendText]) {
NSMutableString *emailBody = [[NSMutableString alloc] initWithString:#"Your Email Body"];
picker.messageComposeDelegate = self;
picker.recipients = [NSArray arrayWithObject:#"123456789"];
[picker setBody:emailBody];// your recipient number or self for testing
picker.body = emailBody;
NSLog(#"Picker -- %#",picker.body);
[self presentModalViewController:picker animated:YES];
NSLog(#"SMS fired");
}
I am trying to download images from server and display in 320 library's TTThumbsViewController. I am not able to get this working!
Following works for me when I have images locally stored:
//Create thumbnails
[ImageUtils checkAndSaveThumbnail:imageName andSize:CGSizeMake(100.0, 100.0) andLocation:NO andPrefixof:#"small"];
NSString *fullImageName = [NSString stringWithFormat:#"documents://%#",imageName];
NSString *imageSmallName = [NSString stringWithFormat:#"documents://small-%#",imageName];
NSString *caption = [tempDict objectForKey:#"Comment"];
UIImage *tempImage = [UIImage imageWithContentsOfFile:[appDelegate filePath:imageName]];
MockPhoto *tempPicture = [[MockPhoto alloc] initWithURL:fullImageName smallURL:imageSmallName size:tempImage.size caption:caption photoname:imageName];
[photoArray addObject:tempPicture];
Adding photoArray into MockPhotoSource:
self.photoSource = [[MockPhotoSource alloc]
initWithType:MockPhotoSourceNormal
title:#"Photos"
photos:photoArray
photos2:nil
];
[photoArray release];
...But when I give download location like following it doesn't work! Doesn't show me thumbnails and neither large pics!
NSString *url = [delegate downloadImageUrl];
MockPhoto *tempPicture = [[MockPhoto alloc] initWithURL:url smallURL:url size:tempImage.size caption:caption photoname:imageName];
[photoArray addObject:tempPicture];
I have been using same same URL with AsyncImage and it downloads image and show in ImageView fine!
NSURL *url = [NSURL URLWithString:[delegate downloadImageUrl]];
UIImageView *profileimage = [[UIImageView alloc] init];
AsyncImageView* asyncImage = [[[AsyncImageView alloc] initWithFrame:CGRectMake(0, 10, 60, 60)] autorelease];
asyncImage.imageName = [[users objectAtIndex:indexPath.row] objectForKey:#"Key"];
[asyncImage loadImageFromURL:url];
[profileimage addSubview:asyncImage];
Could you please let me know what's wrong am I doing with MockPhoto?
Thanks.
I want to display or load multiple images from a server and load it in tableview or image view ...if a single url with image is coming then imageview or tableview loads the image, but more that one image is coming then it did not load the multiple images,
my code is
NSString *urlVal = #"http://at.azinova.info/green4care/iphone/viewImage.php?id=";
NSString *urlVal1 = [urlVal stringByAppendingString:selectedCountryw];
NSURL *url1 = [NSURL URLWithString:urlVal1];
NSString *resultString = [NSString stringWithContentsOfURL:url1 encoding:NSUTF8StringEncoding error:nil];
resultString=[resultString stringByReplacingOccurrencesOfString:#"\n" withString:#""];
NSArray *profileedit = [resultString componentsSeparatedByString:#"#***#"];
lbl.text = resultString;
[web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:lbl.text]]];
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:#selector(tick) userInfo:nil repeats:YES];
UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:#"ALERT" message:resultString delegate:self cancelButtonTitle:#"ok" otherButtonTitles:nil];
[alert1 show];
[alert1 release];
selectedCountryw is just an id
resultstring is the url from the server ,it may be one image or more than one image
You need to create a function that takes a parameter for selectedCountryw
The function returns a UIImage
Call the function every time you need an image, the function makes the request and creates the image
Set the image in the UITableView
Once you've gotten this far, let us know where you are and we'll jump right in and help.
-(UIImage*)getImage:(NSString*)country
{
NSString *urlString = [NSString stringWithFormat: #"http://at.azinova.info/green4care/iphone/viewImage.php?id=%#", country];
NSURL *url = [NSURL URLWithString: urlString];
NSString *strImage = [NSString stringWithContentsOfURL:url];
UIImage *image = [[UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString:strImage]]] retain];
return image;
}
Better yet..Do a search on SO or Google for Lazy TableView Loading. That'll get you started.
Edited to provide additional information:
I'll leave it up to you to optimize.
Better option is the SDwebimage which is very simple to use and is the best library to do this kind of stuff here's the link to that
I am having difficulty with a UIWebView which shows http URLs correctly, but not bundled .pdf files.
I have also read alternative solutions such as using QuartzCore framework, however this does not seem to support multiple pages in PDFs.
Here is the code that works (for google dot com)
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *pdfPath = [[NSBundle mainBundle] pathForResource:#"file" ofType:#".pdf"];
NSURL *pdfURL = [NSURL URLWithString:pdfPath];
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
webFrame.origin.y += kTopMargin - 20.0; // leave from the URL input field and its label
webFrame.size.height -= 00.0;
self.webView = [[[UIWebView alloc] initWithFrame:webFrame] autorelease];
self.webView.backgroundColor = [UIColor whiteColor];
self.webView.scalesPageToFit = YES;
self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.webView.delegate = self;
[self.view addSubview: self.webView];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.google.com"]]];
}
And for the PDF, I have replaced
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.google.com"]]];
with
[self.webView loadRequest:[NSURLRequest requestWithURL:pdfURL]];
My immediate thought was that the iPhone SDK does not support PDF viewing in its webview, however, tutorials like this one seem to show other users having success with this. So do you think I am just missing something in my code?
Thanks.
UIWebView does support pdf when using loadRequest as you are doing.
pathForResource:#"file" ofType:#".pdf"
Take the . out of .pdf
Edit:
[NSURL URLWithString:pdfPath];
Use fileURLWithPath: instead.
Check that pdfPath and pdfURL are what you expect them to be.
NSLog( #"%#" , pdfURL );
trouble loading html file from plist to webView using following code in
FAQDetailViewController.m:
- (void)viewDidLoad {
[super viewDidLoad];
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *WebPath = [Path stringByAppendingPathComponent:WebFile];
UIWebView *tempWeb = [[UIWebView alloc] initWithContentsOfFile:WebPath];
[webView loadData:tempWeb]; //I think my issue is here. I am not understanding how to implement the the code here
[tempWeb release];
}
loaded here with this peace of code in FAQViewController.m:
FAQDetailViewController *faqdvController = [[FAQDetailViewController alloc] initWithNibName:#"FAQDetailView" bundle:[NSBundle mainBundle]];
faqdvController.WebFile = [dictionary objectForKey:#"faqDesc"]; //html file from plist file placed here
faqdvController.hidesBottomBarWhenPushed = NO;
[self.navigationController pushViewController:faqdvController animated:YES];
[faqdvController release];
You can try it this way:
NSString *bundle = [[NSBundle mainBundle] bundlePath];
NSString *webPath = [bundle stringByAppendingPathComponent:{htmlFilename}]
UIWebView* browser = [[UIWebView alloc] initWithFrame:
CGRectMake(0, 0, 200, 300)];
[browser loadRequest:[NSURLRequest requestWithURL:
[NSURL fileURLWithPath:webPath]]];
[self addSubview:browser];
You'll also want to set delegates on the browser so you get informed when the contents have finished loading.