I want to show the power point presentation in iphone .
Is this possible ? because I want to show it in the slide show manner .
I however able to show ppt in the webView . but it is in the vertical manner .
I think if i convert all ppt into images and then show that images into scrollbar but i don't know if this is possible .
so if anyone have idea about this . please share here
Edit..
I am using UIDocumentInteractionController but I am unable to see the ppt .. this is the code ..
NSString * path = [[NSBundle mainBundle] pathForResource:#"Sun2" ofType:#"ppt"];
UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
docController.delegate = self;
[docController retain];
BOOL isValid = [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
You could write some functions that do exactly as you have described, or consider the use of Apple's own UIDocumentInteractionController.
Be sure to implement the delegate method:
(UIViewController*)documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController*)controller
... which will return the view controller that is to push the document controller.
You may also find some of the code in an old question of mine to be helpful:
UIDocumentInteractionController crashing upon exit
Related
In my app, I implemented a QR code reader that directs the app user to another View in the app after scanning any QR code.
I have two Xibs. One is the main screen that loads up when opening the app called demoViewController. The other is the page the app takes you to after scanning a QR code, called yViewController.
On yViewController, I masked the entire page using a UIView called sPage. The reason why I created this UIView is because I needed to implement this code:
[[NSBundle mainBundle] loadNibNamed:#"yViewController" owner:self options:nil];
[self.view addSubview:sPage];
Thats code that takes the user to the second page after scanning. I needed the mask UIView sPage in order to make this method work. And it does work.
However, I think this is screwing up my interface. I had a UIImageView in my sPage View implemented via the
demoViewConroller.m using viewDidLoad:
[topImage setImage: [UIImage imageNamed:#"ylogoREAL.png"]];
The image does not show up.
Additionally, I have some code to animate my view when the keyboard comes up and hides a textfield. This also does not work.
I know the hierarchy is right, because I use a buttonPressed method that works on the sPage View, as well as a method that closes the keyboard when touching the view. But nothing else works.
Can anyone help me figure out why? Im so confused :(
If I understand your error correctly you are calling a function and then ending the line with a semi-colon (programmers force of habit) then going to the next line (maybe) to open the function with a curly bracket.
-(void) function();
{
It needs to not have the semicolon
-(void) function()
{
I'm a bit confused as to what you're trying to achieve, but I'll give it a go
How do you initialize yViewController? I believe you should be using
yViewController = [[UIViewController alloc] initWithNibName:#"yViewController" bundle:[NSBundle mainBundle]];
instead of creating that mask view which loads up yViewController's nib.
Update:
After looking at your code, I believe you want to show a survey page after scanning is done. There are two things you can do
Option 1 - Easier
Present a UIView to the user, using your existing UIViewController (yViewController)
NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:#"Survey" owner:self options:nil];
UIView *view_to_show = [nibs objectAtIndex:0];
[self.view addSubview:view_to_show];
Bear in mind that to be able to dismiss this view later, you will need a reference to it (declare it as a property) and later you can just do [view_to_show setHidden:YES]; or removeFromSuperview
Option 2 - UIViewController option
Create a new UIViewController with your survey view and show that
UIViewController *vc_new = [[UIViewController alloc] initWithNibName:#"Survey" bundle:[NSBundle mainBundle]];
[self presentViewController:vc_new animated:YES completion:nil];
All I needed to do was declare the topImage right under [[NSBundle mainBundle] loadNibNamed:#"yViewController" owner:self options:nil]; . I guess ViewDidLoad was the wrong place to put it in this case!
I have an app that shares with instagram built for iOS5 and now in iOS6, sharing no longer works although canOpenURL returns true and code executes. The images are saved to the documents folder of the application with a .igo extension. This is passed to instagram with com.instagram.exclusivegram.
The code is below, it enters the if statement and displays "here in" but does not open the Share With dialog like it used to at the bottom of the screen.
NSLog(#"%#", _imgToUpload);
NSURL *instagramURL = [NSURL URLWithString:#"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
uidController = [[UIDocumentInteractionController alloc] init];
//imageToUpload is a file path with .igo file extension
uidController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:_imgToUpload]];
uidController.UTI = #"com.instagram.exclusivegram";
uidController.delegate = self;
CGRect navRect = self.view.frame;
[uidController presentOpenInMenuFromRect:navRect inView:[UIApplication sharedApplication].keyWindow animated:YES];
NSLog(#"here in");
}
_imgToUpload is providing the correct filepath as well.
Thank you,
Nick
Just did some testing and found a solution. Do not present in the keyWindow.
[uidController presentOpenInMenuFromRect:navRect inView:self.view animated:YES];
I have tested this and it will fix the problem.
Another reason for the uidocumentinteraction controller not working in iOS6 is that the new action sheet/launch panel (it shows apps available to open the doc) is now used. My app which worked fine launching iBooks with iOS5 failed because I launched from viewDidLoad which was now too early and I got an error on the current view controller 'whose view is not in the window hierarchy' so I changed my code to performselector after delay of 1 second. The app now calls iBooks via the new panel.
I'm trying to show TXT file (ASCII) into UIVewView. For example, using the site www.partisani.net/35.txt in Safari on MacBook works fine, Safari on iPhone doesn't. Safari's iPhone shows the file with another layout. Could someone help me, please?
As far as I can tell, the layout of the file on the Mac vs iOS is exactly the same. Are you talking about text wrapping? You can see that on the Mac by resizing the browser.
If you want to handle the line length differently you'll need to do so by setting up scrolling.
UPDATE with more detail:
This "sort of" changes the original content :). Basically, you need to tweak both the contentSize of the webview and embed the text file in some boilerplate HTML to reflow the text rather than have the default viewport width assigned to the text document. The latter I accomplish with something like:
NSURL* url = [NSURL URLWithString:#"http://www.partisani.net/35.txt"];
UIWebView* vw = (UIWebView*)self.view;
vw.delegate = self;
NSData* Data = [NSData dataWithContentsOfURL:url];
NSString* aStr = [[NSString alloc] initWithData:Data encoding:NSASCIIStringEncoding];
NSString* responseStr = [NSString stringWithFormat:
#"<HTML>"
"<head>"
"<title>Text View</title>"
"</head>"
"<BODY>"
"<pre>"
"%#"
"/pre>"
"</BODY>"
"</HTML>",
aStr];
[vw loadHTMLString:responseStr baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
[aStr release];
The vw.delegate = self is important, as you also need to have your controller conform to the UIWebViewDelegate protocol and implement the webViewDidFinishLoad: method. There you can set the scroll width and height of your webview as needed:
- (void) webViewDidFinishLoad:(UIWebView *)webview {
UIScrollView* sview = (UIScrollView*)[[webview subviews] objectAtIndex:0];
sview.contentSize = CGSizeMake(1000, 800);
}
This is an extremely barebones implementation--presumably you would also want logic to calculate the necessary width and height based upon the loaded text rather than use constants as shown here; you'll need some parsing logic associated with the original data for that, but this should get you started.
Setting the scalesPageToFit property to yes might fix your problem.
I'm not sure this is actually something to do with TXT or ASCII, but rather the UIWebview resizing the content.
The file you mentioned loaded into a landscape ipad screen has exactly the same layout as on Mac Safari:
You can change whether or not the UIWebView scales its content with the scalesPageToFit property.
My app needs to open some file types in other apps, like dropbox app does, it could list the installed apps which could open specific types of file.
How can get the app list?
You'll want to use UIDocumentInteractionController. See also the Document Interaction Programming Guide.
You can use QLPreviewController from the official docs.
Expanding on jtbandes's answer, here's the code that worked for me:
NSURL *url = [NSURL fileURLWithPath:filePath];
UIDocumentInteractionController *popup = [UIDocumentInteractionController interactionControllerWithURL:url];
[popup setDelegate:self];
[popup presentPreviewAnimated:YES];
And don't forget to include this in your H file:
#interface MyViewController : UIViewController <UIDocumentInteractionControllerDelegate>
Also worth noting: this will open a new fullscreen view that has a Document Viewer, as well as the Share button that offers all the various apps that can open this file. If you're just looking for the Share popup, equivalent to the UIActivityViewController, this will do it, but with some extra functionality you may not want.
In my app i want to put my website's url on home screen and on clicking on it i want it to be open as a WebView.
How should i go for this.
Thanks,
Previous commenter is incorrect. You can open any hyperlink either externally with Safari or internally with a UIWebView.
Add a UIWebViewController to your project. Then, instantiate an instance of a the UIWebViewController that will be shown inside your app--you'll do this by declaring a property & synthesizing it within your main view controller (which will need to be declared as a UIWebViewDelegate), such as:
#interface MyMainViewController: UIViewController <UIWebViewDelegate> {
// Your implementation code here
}
When a user taps the button (assuming you make it a button, rather than just a text hyperlink), you instruct your app to add the UIWebView to the view stack, loading the correct link. You'll want to either do this within a modal view or within a navigation stack so your users can get back out of the web view, of course.
In your MyMainViewController implementation file, something like this:
-(void) showWebView {
// NOTE: I have not tested this, just prototyping
// off the top of my head
UIWebView *myWebView = [[UIWebView alloc] init];
myWebView.delegate = self;
NSURL *homeUrl = [[NSURL alloc] initWithString:#"http://example.com"];
NSURLRequest *homeRequest = [NSURLRequest requestWithURL:homeURL];
[myWebView loadRequest:homeRequest];
[self.presentModalViewController: myWebView animated:YES];
// Don't forget to release objects when you're done
[myWebView release]; // etc.
}
Now, this is off the top of my head from what I know and have done. But I hope you get the general idea. I offer no warranty of any kind here, but do guarantee this is entirely possible with minimal headache. If you get stuck, check out the developer references for UIWebView. Apple's docs are top-notch & show great examples to get you up and running quickly.
Best.