Simple iPhone image viewer howto - iphone

I need to develop simple image viewer, much like the default iPhone Photos application, but for images located on remote server. I don't have any point where to start as I don't have any experience yet with such task (how to make a slideshow and how to handle animations when user slides photos with his finger etc.)
Can you please point me to some source - docs, howtos or sample project of such a kind?

I recommend you start with Joe Hewitt's three20 library (introductory text here). In the TTCatalog sample app, you will find a photo browser and three20 has been designed to easily use photos from remote servers.

Try this one https://github.com/mwaterfall/MWPhotoBrowser

Visit http://www.raywenderlich.com/1845/how-to-create-a-simple-iphone-app-tutorial-part-2

Might I recommend Titanium from Appcelerator? I have worked in both xcode and titanium and for quick and dirty projects, titanium might work. Lots of demos out there.

Here's my implementation:
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
self.startX = scrollView.contentOffset.x;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
//NSLog(#"scrollViewDidEndDragging");
self.endX = scrollView.contentOffset.x;
self.photoIdx = (int)self.startX / Normalize(1160);
if (decelerate == FALSE)
{
int intoThePhoto = (int)self.photoScrollView.contentOffset.x % Normalize(1160);
if (intoThePhoto < Normalize(1060/2))
[scrollView setContentOffset:CGPointMake(Normalize(1160)*self.photoIdx,0) animated:YES];
else
[scrollView setContentOffset:CGPointMake(Normalize(1160)*(self.photoIdx+1),0) animated:YES];
}
}
-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
if ((self.endX - self.startX) > 0 && self.photoIdx < ([self.photos count] -1))
[scrollView setContentOffset:CGPointMake(Normalize(1160)*(self.photoIdx+1),0) animated:YES];
else if ((self.endX - self.startX) < 0 && self.photoIdx != 0)
[scrollView setContentOffset:CGPointMake(Normalize(1160)*(self.photoIdx-1),0) animated:YES];
}

Related

Status Bar issue

As you can see from my image, the status bar is displaying on top of my table view and i don't understand what i have done wrong for this to happen. i am sure that it will be a simple fix and i'm just missing it.
Any help will be much appreciated, Thanks!
you can avoid this problem by writing below code in ViewDidLoad method...
float SystemVersion=[[[UIDevice currentDevice] systemVersion] floatValue];
if(SystemVersion<7.0f)
{
//Currently your app is running in IOS6 or older version. So you need not to do anything.
}
else
{
// Currently your app is running in IOS7. Do the following.
CGRect TempRect;
for(UIView *sub in [[self view] subviews])
{
TempRect=[sub frame];
TempRect.origin.y+=20.0f; //Height of status bar
[sub setFrame:TempRect];
}
}
let me know it is working or not my friend!!!
Happy Coding!!!!
like this.. In Autosizing of Custom bar...Only connect to upper side....
Let me know it is working or not!!!
Happy Coding!!

Any ideas on how to implement pull to refresh with KIF Tests?

This is pretty open-ended.
Does anyone have an idea as to how to test pull-to-refresh functionality in KIF Tests?
Simply dragging from the top of the screen down to the bottom of the screen would do that, right? KIF has the following method implemented in the UIView-KIFAdditions category:
- (void)dragFromPoint:(CGPoint)startPoint toPoint:(CGPoint)endPoint;
I went ahead and created the following test step for simple dragging operations:
+ (id)stepToDragFromStartPoint:(CGPoint)startPoint toEndPoint:(CGPoint)endPoint
{
NSString *description = [NSString stringWithFormat:#"Simulate dragging finger from point %.1f,%.1f to point %.1f,%.1f", startPoint.x, startPoint.y, endPoint.x, endPoint.y];
return [KIFTestStep stepWithDescription:description executionBlock:^(KIFTestStep *step, NSError **error) {
UIView *viewToSwipe = [UIApplication sharedApplication].keyWindow.subviews.lastObject;
[viewToSwipe dragFromPoint:startPoint toPoint:endPoint];
return KIFTestStepResultSuccess;
}];
}
Hope that helps!
A while after posting this question, KIF has developed built-in "pull to refresh" functionality. See the following methods in KIFUITestActor
- (void)pullToRefreshViewWithAccessibilityLabel:(NSString *)label pullDownDuration:(KIFPullToRefreshTiming) pullDownDuration;
- (void)pullToRefreshViewWithAccessibilityLabel:(NSString *)label value:(NSString *)value;
- (void)pullToRefreshAccessibilityElement:(UIAccessibilityElement *)element inView:(UIView *)viewToSwipe pullDownDuration:(KIFPullToRefreshTiming) pullDownDuration;

any open source library for PDF reader

QUESTION UPDATE
Their is any alternative of fastPDF reader for iphone app. Or any open source library which we can use full in pdf reader feature.
Thanks.
There are three options: buy a FastPdfKit license choosing from Basic, Plus and Extra versions
instead of that you can show any loding... image and present it for 5 seconds. so no one will see the fastpdf logo.
You can sublass MFDocumentViewController and hide the splash screen by hiding the child Image View:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.view.subviews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) {
if ([view isKindOfClass:[UIImageView class]]) {
// hide the splash screen
view.hidden = YES;
}
}];
}
But before publishing your app, carefully check first the license. I think the free license is an attribution license, so just leaving out the splash screen won't do it

Show PDF on a UIScrollView

I found an example code for showing PDF file on a UIScrollView with horizontal scrolling. It works fine, but problem is it shows only 2 pages of PDF. I tried in my best to figure out the issue, but I couldn't figure it. Can you please give me help?
I looked at that sample project you pointed to in this question and like you, I can see it only displays two pages of whatever PDF file it's given to display.
The problem with the sample code comes in the PDFViewController.m file. For these lines:
PDFScrollView *page = [self dequeueRecycledPage];
if (page == nil) {
page = [[[PDFScrollView alloc] initWithPage:index + 1 frame:[self frameForPageAtIndex:index]] autorelease];
}
I added
else {
[page setPage: index inFrame:[self frameForPageAtIndex: index]];
}
And also these new lines into PDFScrollView.h
- (void) setPage: (NSInteger) onPage inFrame:(CGRect)frame;
And PDFScrollView.m
- (void) setPage: (NSInteger) onPage inFrame:(CGRect) frame
{
if(pdfView)
{
[pdfView removeFromSuperview];
[pdfView release];
}
self.frame = frame;
self.index = onPage;
pdfView = [[PDFViewTiled alloc] initWithPage:onPage frame:self.frame];
[self addSubview:pdfView];
}
This isn't a perfect fix. You'll see the drawing isn't proper, especially when backing up pages. I'll leave that to you as an exercise to take care of, but hopefully this is a nice start.
And I hope it helps you out.

alert view present on iPhone

I want to check whether the UIALertView is present on the screen or not, though I have done it by using the following method:
-(BOOL) isAlertShowing
{
for (UIWindow* window in [UIApplication sharedApplication].windows) {
NSArray* subviews = window.subviews;
if ([subviews count] > 0)
if ([[subviews objectAtIndex:0] isKindOfClass:[UIAlertView class]])
return YES;
}
return NO;
}
but I came to know that it is undocumented one. So, please tell me authenticate way of doing it.
In an app I submitted (and is approved), I have used a similar approach (see iPhone: detecting if a UIAlert/UIActionSheet are open)...
I don't see why you think it's not a valid method - I'd try it.