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.
Related
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
i am doing one simple apps project and using storyboards. but i am confuse to use either storyboard or xib file in my project ?
which of the best as performance base.
There is no performance improvements in Storyboard versus Xib files, they both are modified XML files. However storyboards are meant to be easier to use and give better overall look of your app. My personal experience is that storyboards are OK for really small apps(let's say 3-4 screens at top), however if you have complex app with 10-15 screen storyboards becomes a nightmare to maintain.
UPDATE
Also what I don't like about storyboards, is that if I wan't to reuse some screen in other application, I'll have to copy .m and .h files, and then search through storyboard to find my related interface file and put it inside new storyboard. Without them I'll just copy paste h,m,xib files(which I usually put in separate folder) for each screen at new project and use them.
Solution for you last comment :
you can use following code for designing UIButton dynamically-
int yPosition = 0;
for (int i = 0; i<10; i++){
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
[aButton setBackgroundColor:[UIColor blackColor]];
[aButton setTitle:[NSString stringWithFormat:#"Button %d",index] forState:UIControlStateNormal];
[aButton setFrame:CGRectMake(20, yPosition, 100, 50)];
[aButton addTarget:self action:#selector(aButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[aView addSubview:aButton];
yPosition += 50;
}
- (IBAction)aButtonClicked:(id)sender
{
NSLog(#"Clicked on button with title %#",[sender titleLabel].text);
}
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
So I got this piece of code, I want to show a picture on my view:
imgLogo = [[UIImageView alloc] init];
[imgLogo setFrame:CGRectMake(60, 200, 200, 200)];
[imgLogo setImage:[UIImage imageNamed:#"MyFrigginAwesomeLogo"]];
[self.view addSubview:imgLogo];
But the problem is that it works correctly when testing it on the simulator(iOS 7) but it doesn't show anything on my iPhone(4S with iOS7) itself.
Answer added from Comment:
The iOS devices are case sensitive, but the simulator is not. Make sure you are trying to load the exact filename in order for them to be found.
Try using the designated initializer for UIImageView instead of just init:
NSString *logoName = #"MyFriggingAwesomeLogo";
imgLogo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:logoName]];
imgLogo.frame = CGRectOffset(imgLogo.frame, 60, 200);
[self.view addSubview:imgLogo];
It's also possible that you've added the image resource to only the simulator target. In your bundle settings Build Phases, make sure you have the image listed in Copy Bundle Resources.
I have a UIPickerView which works correctly, now I want to add a button above it so that I can dismiss it.
and here is my code where I initiate a UIPickerView as well as its dismiss button:
- (UIPickerView *)creatPickerView {
UIPickerView *tempPickerView = [[[UIPickerView alloc]
initWithFrame:CGRectMake(kPickerViewX, kPickerViewY, kPickerViewWidth, kPickerViewHeight)] autorelease];
tempPickerView.showsSelectionIndicator = YES;
tempPickerView.delegate = self;
tempPickerView.dataSource = self;
UIButton *pickerButton = [[UIButton alloc] initWithFrame:CGRectMake(270, -32, 50, 32)];
[pickerButton setBackgroundImage:[UIImage imageNamed:#"hidePicker.png"]
forState:UIControlStateNormal];
[pickerButton addTarget:self action:#selector(hidePicker)
forControlEvents:UIControlEventTouchUpInside];
[tempPickerView addSubview:pickerButton];
[pickerButton release];
[self.view addSubview:tempPickerView];
return tempPickerView;
}
and it works well on my iPhone 4.3 Simulator, like this:
apparently there is a button on the upper right of the pickerView,
problem is, when I run the app in my device - a 5.0.1 iPhone4 and a 4.2.1 iTouch, the button is missed like it has never been added to the pickerView.
Can anyone help me with this?
Thanks a lot and a lot!
I found the reason, it seems the png has some problem,
after I change another png, it comes up in the screen!
but the real problem is that I place the button outside of the pickerView which results in the button's untouchableness.
But anyway the pickure is only a small problem.