diff --git a/Classes/MWPhotoBrowser.h b/Classes/MWPhotoBrowser.h index 5610b7a..8e778fa 100644 --- a/Classes/MWPhotoBrowser.h +++ b/Classes/MWPhotoBrowser.h @@ -27,7 +27,11 @@ // Navigation & controls UIToolbar *toolbar; NSTimer *controlVisibilityTimer; + UIBarButtonItem *previousButton, *nextButton; + BOOL performingLayout; + BOOL rotating; + } // Init @@ -51,6 +55,7 @@ - (CGRect)frameForPagingScrollView; - (CGRect)frameForPageAtIndex:(NSUInteger)index; - (CGSize)contentSizeForPagingScrollView; +- (CGPoint)contentOffsetForPageAtIndex:(int)index; - (CGRect)frameForNavigationBarAtOrientation:(UIInterfaceOrientation)orientation; - (CGRect)frameForToolbarAtOrientation:(UIInterfaceOrientation)orientation; @@ -66,5 +71,8 @@ - (void)setControlsHidden:(BOOL)hidden; - (void)toggleControls; +// Properties +- (void)setInitialPageIndex:(int)index; + @end diff --git a/Classes/MWPhotoBrowser.m b/Classes/MWPhotoBrowser.m index 0ce365b..1e9781b 100644 --- a/Classes/MWPhotoBrowser.m +++ b/Classes/MWPhotoBrowser.m @@ -28,6 +28,8 @@ // Defaults self.wantsFullScreenLayout = YES; currentPageIndex = 0; + performingLayout = NO; + rotating = NO; } return self; @@ -57,6 +59,8 @@ [visiblePages release]; [recycledPages release]; [toolbar release]; + [previousButton release]; + [nextButton release]; } - (void)dealloc { @@ -65,6 +69,8 @@ [visiblePages release]; [recycledPages release]; [toolbar release]; + [previousButton release]; + [nextButton release]; [super dealloc]; } @@ -87,6 +93,7 @@ pagingScrollView.showsVerticalScrollIndicator = NO; pagingScrollView.backgroundColor = [UIColor blackColor]; pagingScrollView.contentSize = [self contentSizeForPagingScrollView]; + pagingScrollView.contentOffset = [self contentOffsetForPageAtIndex:currentPageIndex]; [self.view addSubview:pagingScrollView]; // Setup pages @@ -105,18 +112,18 @@ [self.view addSubview:toolbar]; // Toolbar Items - UIBarButtonItem *previousImage = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"UIBarButtonItemArrowLeft.png"] style:UIBarButtonItemStylePlain target:self action:@selector(gotoPreviousPage)]; - UIBarButtonItem *nextImage = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"UIBarButtonItemArrowRight.png"] style:UIBarButtonItemStylePlain target:self action:@selector(gotoNextPage)]; + previousButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"UIBarButtonItemArrowLeft.png"] style:UIBarButtonItemStylePlain target:self action:@selector(gotoPreviousPage)]; + nextButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"UIBarButtonItemArrowRight.png"] style:UIBarButtonItemStylePlain target:self action:@selector(gotoNextPage)]; UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; NSMutableArray *items = [[NSMutableArray alloc] init]; [items addObject:space]; - if (photos.count > 1) [items addObject:previousImage]; + if (photos.count > 1) [items addObject:previousButton]; [items addObject:space]; - if (photos.count > 1) [items addObject:nextImage]; + if (photos.count > 1) [items addObject:nextButton]; [items addObject:space]; [toolbar setItems:items]; [items release]; - [previousImage release], [nextImage release], [space release]; + [space release]; // Super [super viewDidLoad]; @@ -157,6 +164,9 @@ // Layout subviews - (void)performLayout { + // Flag + performingLayout = YES; + // Toolbar toolbar.frame = [self frameForToolbarAtOrientation:self.interfaceOrientation]; @@ -176,16 +186,14 @@ for (ZoomingScrollView *page in visiblePages) { page.frame = [self frameForPageAtIndex:page.index]; [page setMaxMinZoomScalesForCurrentBounds]; - page.zoomScale = page.minimumZoomScale; } - // adjust contentOffset to preserve page location based on values collected prior to location - CGFloat pageWidth = pagingScrollView.bounds.size.width; - CGFloat newOffset = indexPriorToLayout * pageWidth; - pagingScrollView.contentOffset = CGPointMake(newOffset, 0); + // Adjust contentOffset to preserve page location based on values collected prior to location + pagingScrollView.contentOffset = [self contentOffsetForPageAtIndex:indexPriorToLayout]; - // Reset page + // Reset currentPageIndex = indexPriorToLayout; + performingLayout = NO; } @@ -351,6 +359,12 @@ return CGSizeMake(bounds.size.width * photos.count, bounds.size.height); } +- (CGPoint)contentOffsetForPageAtIndex:(int)index { + CGFloat pageWidth = pagingScrollView.bounds.size.width; + CGFloat newOffset = index * pageWidth; + return CGPointMake(newOffset, 0); +} + - (CGRect)frameForNavigationBarAtOrientation:(UIInterfaceOrientation)orientation { CGFloat height = UIInterfaceOrientationIsPortrait(orientation) ? 44 : 32; return CGRectMake(0, 20, self.view.bounds.size.width, height); @@ -366,6 +380,8 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView { + if (performingLayout || rotating) return; + // Tile pages [self tilePages]; @@ -402,6 +418,10 @@ self.title = nil; } + // Buttons + previousButton.enabled = (currentPageIndex > 0); + nextButton.enabled = (currentPageIndex < photos.count-1); + } - (void)jumpToPageAtIndex:(int)index { @@ -496,6 +516,7 @@ // Remember page index before rotation pageIndexBeforeRotation = currentPageIndex; + rotating = YES; } @@ -510,4 +531,21 @@ } +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { + rotating = NO; +} + +#pragma mark - +#pragma mark Properties + +- (void)setInitialPageIndex:(int)index { + if (![self isViewLoaded]) { + if (index < 0 || index >= photos.count) { + currentPageIndex = 0; + } else { + currentPageIndex = index; + } + } +} + @end diff --git a/Classes/Menu.m b/Classes/Menu.m index 75afa0c..c061bb2 100644 --- a/Classes/Menu.m +++ b/Classes/Menu.m @@ -99,6 +99,7 @@ // Create browser MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithPhotos:photos]; + // [browser setInitialPageIndex:1]; Can be changed if desired [self.navigationController pushViewController:browser animated:YES]; [browser release]; [photos release]; diff --git a/Classes/ZoomingScrollView.m b/Classes/ZoomingScrollView.m index b19fb77..5836e3e 100644 --- a/Classes/ZoomingScrollView.m +++ b/Classes/ZoomingScrollView.m @@ -77,10 +77,12 @@ // Get and display image - (void)displayImage { - if (index != NSNotFound) { + if (index != NSNotFound && photoImageView.image == nil) { // Reset - self.zoomScale = 1; // Reset zoom scale to 1 + self.maximumZoomScale = 1; + self.minimumZoomScale = 1; + self.zoomScale = 1; self.contentSize = CGSizeMake(0, 0); // Get image @@ -103,7 +105,6 @@ // Set zoom to minimum zoom [self setMaxMinZoomScalesForCurrentBounds]; - self.zoomScale = self.minimumZoomScale; } else { @@ -114,6 +115,7 @@ } } + [self setNeedsLayout]; } // Image failed so just show black! @@ -126,9 +128,17 @@ - (void)setMaxMinZoomScalesForCurrentBounds { + // Reset + self.maximumZoomScale = 1; + self.minimumZoomScale = 1; + self.zoomScale = 1; + + // Bail + if (photoImageView.image == nil) return; + // Sizes CGSize boundsSize = self.bounds.size; - CGSize imageSize = photoImageView.bounds.size; + CGSize imageSize = photoImageView.frame.size; // Calculate Min CGFloat xScale = boundsSize.width / imageSize.width; // the scale needed to perfectly fit the image width-wise @@ -136,17 +146,21 @@ CGFloat minScale = MIN(xScale, yScale); // use minimum of these to allow the image to become fully visible // Calculate Max - CGFloat maxScale = 1.0; + CGFloat maxScale = 2.0; // Allow double scale // on high resolution screens we have double the pixel density, so we will be seeing every pixel if we limit the // maximum zoom scale to 0.5. - //if ([UIScreen instancesRespondToSelector:@selector(scale)]) maxScale = 1.0 / [[UIScreen mainScreen] scale]; - - // Don't let minScale exceed maxScale. (If the image is smaller than the screen, we don't want to force it to be zoomed.) - if (minScale > maxScale) minScale = maxScale; - - // Set - self.maximumZoomScale = maxScale; - self.minimumZoomScale = minScale; + //if ([UIScreen instancesRespondToSelector:@selector(scale)]) maxScale = maxScale / [[UIScreen mainScreen] scale]; + + // If image is smaller than the screen then ensure we show it at + // min scale of 1 + if (xScale > 1 && yScale > 1) { + minScale = 1.0; + } + + // Set + self.maximumZoomScale = maxScale; + self.minimumZoomScale = minScale; + self.zoomScale = minScale; // Reset position photoImageView.frame = CGRectMake(0, 0, photoImageView.frame.size.width, photoImageView.frame.size.height); diff --git a/MWPhotoBrowser-Info.plist b/MWPhotoBrowser-Info.plist index d0ee3ec..1b7963f 100644 --- a/MWPhotoBrowser-Info.plist +++ b/MWPhotoBrowser-Info.plist @@ -26,6 +26,8 @@ NSMainNibFile MainWindow + NSMainNibFile~ipad + MainWindow-iPad UIApplicationExitsOnSuspend diff --git a/MWPhotoBrowser.xcodeproj/Michael.mode1v3 b/MWPhotoBrowser.xcodeproj/Michael.mode1v3 index 46b65d5..3d2e385 100644 --- a/MWPhotoBrowser.xcodeproj/Michael.mode1v3 +++ b/MWPhotoBrowser.xcodeproj/Michael.mode1v3 @@ -274,7 +274,6 @@ 4CC82BC51266798B00C05633 4C48EFD4126F90CA00F85546 4C48EFD3126F90C600F85546 - 29B97317FDCFA39411CA2CEA 1C37FBAC04509CD000000102 1C37FAAC04509CD000000102 @@ -307,7 +306,7 @@ 363 RubberWindowFrame - 230 184 1440 861 0 0 1920 1178 + 240 174 1440 861 0 0 1920 1178 Module PBXSmartGroupTreeModule @@ -337,29 +336,30 @@ _historyCapacity 0 bookmark - 4C667CBC1270D4560008B630 + 4C4157121277373000C96767 history 4C75D4A3126B7ABF004D0ECF 4C48EFE8126F932C00F85546 - 4C3EAFC9126FC70A00C7CF25 - 4C3EAFCA126FC70A00C7CF25 4C3EAFCB126FC70A00C7CF25 4C3EAFCC126FC70A00C7CF25 4C3EAFCD126FC70A00C7CF25 4C3EAFD0126FC70A00C7CF25 - 4C667C591270C8370008B630 - 4C667C5A1270C8370008B630 4C667C5D1270C8EC0008B630 - 4C667C5E1270C8EC0008B630 - 4C667C601270C8EC0008B630 4C667C6E1270CA3A0008B630 4C667C6F1270CA3A0008B630 - 4C667CAC1270CF150008B630 - 4C667CB41270D1230008B630 4C667CB51270D1230008B630 - 4C667CB61270D1230008B630 - 4C667CAB1270CF150008B630 + 4C41556212770FD300C96767 + 4C41559C1277143800C96767 + 4C415675127728CC00C96767 + 4C4156B812772E4100C96767 + 4C4156BA12772E4100C96767 + 4C4156CD127731D900C96767 + 4C4156E01277331E00C96767 + 4C4157051277364000C96767 + 4C41570E1277373000C96767 + 4C41570F1277373000C96767 + 4C4157101277373000C96767 SplitCount @@ -373,7 +373,7 @@ Frame {{0, 0}, {1055, 815}} RubberWindowFrame - 230 184 1440 861 0 0 1920 1178 + 240 174 1440 861 0 0 1920 1178 Module PBXNavigatorGroup @@ -393,7 +393,7 @@ Frame {{0, 820}, {1055, 0}} RubberWindowFrame - 230 184 1440 861 0 0 1920 1178 + 240 174 1440 861 0 0 1920 1178 Module XCDetailModule @@ -417,9 +417,9 @@ TableOfContents - 4C667BF61270C1200008B630 + 4C41552F12770E7600C96767 1CE0B1FE06471DED0097A5F4 - 4C667BF71270C1200008B630 + 4C41553012770E7600C96767 1CE0B20306471E060097A5F4 1CE0B20506471E060097A5F4 @@ -558,15 +558,15 @@ WindowOrderList 1C530D57069F1CE1000CFCEE - 4C667C011270C1200008B630 - 4C667C021270C1200008B630 + 4C41553A12770E7600C96767 + 4C41553B12770E7600C96767 1CD10A99069EF8BA00B06720 4CC82BC01266793900C05633 - /Users/Michael/My Work/d3i/Projects/MWPhotoBrowser/MWPhotoBrowser.xcodeproj 1C78EAAD065D492600B07095 + /Users/Michael/My Work/d3i/Projects/MWPhotoBrowser/MWPhotoBrowser.xcodeproj WindowString - 230 184 1440 861 0 0 1920 1178 + 240 174 1440 861 0 0 1920 1178 WindowToolsV3 @@ -587,7 +587,7 @@ PBXProjectModuleGUID 1CD0528F0623707200166675 PBXProjectModuleLabel - + MWPhotoBrowser.m StatusBarVisibility @@ -604,6 +604,8 @@ 432pt + BecomeActive + ContentConfiguration PBXProjectModuleGUID @@ -643,7 +645,7 @@ TableOfContents 4CC82BC01266793900C05633 - 4C667BF81270C1200008B630 + 4C41553112770E7600C96767 1CD0528F0623707200166675 XCMainBuildResultsModuleGUID @@ -739,10 +741,10 @@ Frame {{587, 0}, {700, 389}} RubberWindowFrame - 633 402 1287 776 0 0 1920 1178 + 348 284 1287 776 0 0 1920 1178 RubberWindowFrame - 633 402 1287 776 0 0 1920 1178 + 348 284 1287 776 0 0 1920 1178 Module PBXDebugSessionModule @@ -765,18 +767,18 @@ TableOfContents 1CD10A99069EF8BA00B06720 - 4C667BF91270C1200008B630 + 4C41553212770E7600C96767 1C162984064C10D400B95A72 - 4C667BFA1270C1200008B630 - 4C667BFB1270C1200008B630 - 4C667BFC1270C1200008B630 - 4C667BFD1270C1200008B630 - 4C667BFE1270C1200008B630 + 4C41553312770E7600C96767 + 4C41553412770E7600C96767 + 4C41553512770E7600C96767 + 4C41553612770E7600C96767 + 4C41553712770E7600C96767 ToolbarConfiguration xcode.toolbar.config.debugV3 WindowString - 633 402 1287 776 0 0 1920 1178 + 348 284 1287 776 0 0 1920 1178 WindowToolGUID 1CD10A99069EF8BA00B06720 WindowToolIsVisible @@ -805,25 +807,25 @@ PBXProjectModuleGUID 1CDD528C0622207200134675 PBXProjectModuleLabel - MWPhotoBrowser.m + ZoomingScrollView.m StatusBarVisibility GeometryConfiguration Frame - {{0, 0}, {1920, 805}} + {{0, 0}, {1247, 593}} RubberWindowFrame - 0 4 1920 1174 0 0 1920 1178 + 50 216 1247 962 0 0 1920 1178 Module PBXNavigatorGroup Proportion - 1920pt + 1247pt Proportion - 805pt + 593pt ContentConfiguration @@ -836,9 +838,9 @@ GeometryConfiguration Frame - {{0, 810}, {1920, 323}} + {{0, 598}, {1247, 323}} RubberWindowFrame - 0 4 1920 1174 0 0 1920 1178 + 50 216 1247 962 0 0 1920 1178 Module PBXProjectFindModule @@ -847,7 +849,7 @@ Proportion - 1133pt + 921pt Name @@ -861,13 +863,13 @@ TableOfContents 1C530D57069F1CE1000CFCEE - 4C667C391270C5340008B630 - 4C667C3A1270C5340008B630 + 4C41555B12770FA000C96767 + 4C41555C12770FA000C96767 1CDD528C0622207200134675 1CD0528E0623707200166675 WindowString - 0 4 1920 1174 0 0 1920 1178 + 50 216 1247 962 0 0 1920 1178 WindowToolGUID 1C530D57069F1CE1000CFCEE WindowToolIsVisible @@ -927,7 +929,7 @@ TableOfContents 1C78EAAD065D492600B07095 - 4C667BFF1270C1200008B630 + 4C41553812770E7600C96767 1C78EAAC065D492600B07095 ToolbarConfiguration diff --git a/MWPhotoBrowser.xcodeproj/Michael.pbxuser b/MWPhotoBrowser.xcodeproj/Michael.pbxuser index a670c8c..a8ed8ab 100644 --- a/MWPhotoBrowser.xcodeproj/Michael.pbxuser +++ b/MWPhotoBrowser.xcodeproj/Michael.pbxuser @@ -10,7 +10,7 @@ 1D3623250D0F684500981E51 /* MWPhotoBrowserAppDelegate.m */ = { uiCtxt = { sepNavIntBoundsRect = "{{0, 0}, {1965, 1092}}"; - sepNavSelRange = "{469, 0}"; + sepNavSelRange = "{715, 0}"; sepNavVisRange = "{0, 2237}"; }; }; @@ -22,16 +22,16 @@ }; 28D7ACF60DDB3853001CB0EB /* MWPhotoBrowser.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1474, 1032}}"; - sepNavSelRange = "{572, 0}"; - sepNavVisRange = "{0, 1571}"; + sepNavIntBoundsRect = "{{0, 0}, {1474, 1057}}"; + sepNavSelRange = "{661, 0}"; + sepNavVisRange = "{0, 1766}"; }; }; 28D7ACF70DDB3853001CB0EB /* MWPhotoBrowser.m */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1859, 6344}}"; - sepNavSelRange = "{7542, 0}"; - sepNavVisRange = "{9800, 2274}"; + sepNavIntBoundsRect = "{{0, 0}, {1265, 6760}}"; + sepNavSelRange = "{5312, 0}"; + sepNavVisRange = "{9362, 806}"; sepNavWindowFrame = "{{15, 299}, {938, 874}}"; }; }; @@ -132,56 +132,37 @@ PBXFileDataSource_Warnings_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 309379108; - PBXWorkspaceStateSaveDate = 309379108; + PBXPerProjectTemplateStateSaveDate = 309792199; + PBXWorkspaceStateSaveDate = 309792199; }; perUserProjectItems = { - 4C3EAFC9126FC70A00C7CF25 /* PBXTextBookmark */ = 4C3EAFC9126FC70A00C7CF25 /* PBXTextBookmark */; - 4C3EAFCA126FC70A00C7CF25 /* PBXTextBookmark */ = 4C3EAFCA126FC70A00C7CF25 /* PBXTextBookmark */; 4C3EAFCB126FC70A00C7CF25 /* PBXTextBookmark */ = 4C3EAFCB126FC70A00C7CF25 /* PBXTextBookmark */; 4C3EAFCC126FC70A00C7CF25 /* PBXTextBookmark */ = 4C3EAFCC126FC70A00C7CF25 /* PBXTextBookmark */; 4C3EAFCD126FC70A00C7CF25 /* PBXTextBookmark */ = 4C3EAFCD126FC70A00C7CF25 /* PBXTextBookmark */; 4C3EAFD0126FC70A00C7CF25 /* PBXTextBookmark */ = 4C3EAFD0126FC70A00C7CF25 /* PBXTextBookmark */; + 4C41556212770FD300C96767 /* PBXTextBookmark */ = 4C41556212770FD300C96767 /* PBXTextBookmark */; + 4C41559C1277143800C96767 /* PBXTextBookmark */ = 4C41559C1277143800C96767 /* PBXTextBookmark */; + 4C415675127728CC00C96767 /* PBXTextBookmark */ = 4C415675127728CC00C96767 /* PBXTextBookmark */; + 4C4156B812772E4100C96767 /* PBXTextBookmark */ = 4C4156B812772E4100C96767 /* PBXTextBookmark */; + 4C4156BA12772E4100C96767 /* PBXTextBookmark */ = 4C4156BA12772E4100C96767 /* PBXTextBookmark */; + 4C4156CD127731D900C96767 /* PBXTextBookmark */ = 4C4156CD127731D900C96767 /* PBXTextBookmark */; + 4C4156E01277331E00C96767 /* PBXTextBookmark */ = 4C4156E01277331E00C96767 /* PBXTextBookmark */; + 4C4157051277364000C96767 /* PBXTextBookmark */ = 4C4157051277364000C96767 /* PBXTextBookmark */; + 4C41570E1277373000C96767 /* PBXTextBookmark */ = 4C41570E1277373000C96767 /* PBXTextBookmark */; + 4C41570F1277373000C96767 /* PBXTextBookmark */ = 4C41570F1277373000C96767 /* PBXTextBookmark */; + 4C4157101277373000C96767 /* PBXTextBookmark */ = 4C4157101277373000C96767 /* PBXTextBookmark */; + 4C4157121277373000C96767 /* PBXTextBookmark */ = 4C4157121277373000C96767 /* PBXTextBookmark */; 4C48EFE8126F932C00F85546 /* PBXTextBookmark */ = 4C48EFE8126F932C00F85546 /* PBXTextBookmark */; - 4C667C591270C8370008B630 /* PBXTextBookmark */ = 4C667C591270C8370008B630 /* PBXTextBookmark */; - 4C667C5A1270C8370008B630 /* PBXTextBookmark */ = 4C667C5A1270C8370008B630 /* PBXTextBookmark */; 4C667C5D1270C8EC0008B630 /* PBXTextBookmark */ = 4C667C5D1270C8EC0008B630 /* PBXTextBookmark */; - 4C667C5E1270C8EC0008B630 /* PBXTextBookmark */ = 4C667C5E1270C8EC0008B630 /* PBXTextBookmark */; - 4C667C601270C8EC0008B630 /* PBXTextBookmark */ = 4C667C601270C8EC0008B630 /* PBXTextBookmark */; 4C667C6E1270CA3A0008B630 /* PBXBookmark */ = 4C667C6E1270CA3A0008B630 /* PBXBookmark */; 4C667C6F1270CA3A0008B630 /* PBXBookmark */ = 4C667C6F1270CA3A0008B630 /* PBXBookmark */; - 4C667CAB1270CF150008B630 /* PBXTextBookmark */ = 4C667CAB1270CF150008B630 /* PBXTextBookmark */; - 4C667CAC1270CF150008B630 /* PBXTextBookmark */ = 4C667CAC1270CF150008B630 /* PBXTextBookmark */; - 4C667CB41270D1230008B630 /* PBXTextBookmark */ = 4C667CB41270D1230008B630 /* PBXTextBookmark */; 4C667CB51270D1230008B630 /* PBXBookmark */ = 4C667CB51270D1230008B630 /* PBXBookmark */; - 4C667CB61270D1230008B630 /* PBXTextBookmark */ = 4C667CB61270D1230008B630 /* PBXTextBookmark */; - 4C667CBC1270D4560008B630 /* PBXTextBookmark */ = 4C667CBC1270D4560008B630 /* PBXTextBookmark */; 4C75D4A3126B7ABF004D0ECF /* PlistBookmark */ = 4C75D4A3126B7ABF004D0ECF /* PlistBookmark */; }; sourceControlManager = 4CC82BC21266793900C05633 /* Source Control */; userBuildSettings = { }; }; - 4C3EAFC9126FC70A00C7CF25 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 4C48EFCB126F8DD900F85546 /* UIImage+Decompress.h */; - name = "UIImage+Decompress.h: 12"; - rLen = 0; - rLoc = 233; - rType = 0; - vrLen = 239; - vrLoc = 0; - }; - 4C3EAFCA126FC70A00C7CF25 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 4C48EFCC126F8DD900F85546 /* UIImage+Decompress.m */; - name = "UIImage+Decompress.m: 13"; - rLen = 0; - rLoc = 271; - rType = 0; - vrLen = 1042; - vrLoc = 0; - }; 4C3EAFCB126FC70A00C7CF25 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 4C48EFD1126F90B100F85546 /* UIViewTap.m */; @@ -222,6 +203,132 @@ vrLen = 968; vrLoc = 0; }; + 4C41556212770FD300C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 4CC82BE41266804500C05633 /* ZoomingScrollView.h */; + name = "ZoomingScrollView.h: 26"; + rLen = 0; + rLoc = 539; + rType = 0; + vrLen = 875; + vrLoc = 0; + }; + 4C41559C1277143800C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 4C75D46E126B659A004D0ECF /* MWPhoto.m */; + name = "MWPhoto.m: 141"; + rLen = 74; + rLoc = 2964; + rType = 0; + vrLen = 1700; + vrLoc = 2141; + }; + 4C415675127728CC00C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 4C415676127728CC00C96767 /* CGGeometry.h */; + name = "CGGeometry.h: 264"; + rLen = 0; + rLoc = 8272; + rType = 0; + vrLen = 2610; + vrLoc = 6334; + }; + 4C415676127728CC00C96767 /* CGGeometry.h */ = { + isa = PBXFileReference; + name = CGGeometry.h; + path = /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGGeometry.h; + sourceTree = ""; + }; + 4C4156B812772E4100C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 4C48EFCB126F8DD900F85546 /* UIImage+Decompress.h */; + name = "UIImage+Decompress.h: 12"; + rLen = 0; + rLoc = 233; + rType = 0; + vrLen = 239; + vrLoc = 0; + }; + 4C4156BA12772E4100C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 1D3623240D0F684500981E51 /* MWPhotoBrowserAppDelegate.h */; + name = "MWPhotoBrowserAppDelegate.h: 19"; + rLen = 0; + rLoc = 342; + rType = 0; + vrLen = 342; + vrLoc = 0; + }; + 4C4156CD127731D900C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 4C48EFCC126F8DD900F85546 /* UIImage+Decompress.m */; + name = "UIImage+Decompress.m: 13"; + rLen = 0; + rLoc = 271; + rType = 0; + vrLen = 1042; + vrLoc = 0; + }; + 4C4156E01277331E00C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 4CC82BE51266804500C05633 /* ZoomingScrollView.m */; + name = "ZoomingScrollView.m: 22"; + rLen = 0; + rLoc = 500; + rType = 0; + vrLen = 2057; + vrLoc = 0; + }; + 4C4157051277364000C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 28D7ACF60DDB3853001CB0EB /* MWPhotoBrowser.h */; + name = "MWPhotoBrowser.h: 34"; + rLen = 0; + rLoc = 661; + rType = 0; + vrLen = 1766; + vrLoc = 0; + }; + 4C41570E1277373000C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 28D7ACF70DDB3853001CB0EB /* MWPhotoBrowser.m */; + name = "MWPhotoBrowser.m: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1310; + vrLoc = 0; + }; + 4C41570F1277373000C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 1D3623250D0F684500981E51 /* MWPhotoBrowserAppDelegate.m */; + name = "MWPhotoBrowserAppDelegate.m: 26"; + rLen = 0; + rLoc = 715; + rType = 0; + vrLen = 2237; + vrLoc = 0; + }; + 4C4157101277373000C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 4C667B2C1270AFCE0008B630 /* Menu.m */; + name = "Menu.m: 102"; + rLen = 0; + rLoc = 3455; + rType = 0; + vrLen = 2578; + vrLoc = 1077; + }; + 4C4157121277373000C96767 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 4C667B2C1270AFCE0008B630 /* Menu.m */; + name = "Menu.m: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1562; + vrLoc = 0; + }; 4C48EFCB126F8DD900F85546 /* UIImage+Decompress.h */ = { uiCtxt = { sepNavIntBoundsRect = "{{0, 0}, {1474, 1057}}"; @@ -231,7 +338,7 @@ }; 4C48EFCC126F8DD900F85546 /* UIImage+Decompress.m */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1474, 1057}}"; + sepNavIntBoundsRect = "{{0, 0}, {1474, 1034}}"; sepNavSelRange = "{271, 0}"; sepNavVisRange = "{0, 1042}"; }; @@ -269,31 +376,11 @@ }; 4C667B2C1270AFCE0008B630 /* Menu.m */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {994, 1625}}"; + sepNavIntBoundsRect = "{{0, 0}, {994, 1651}}"; sepNavSelRange = "{0, 0}"; sepNavVisRange = "{0, 1562}"; }; }; - 4C667C591270C8370008B630 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 4CC82BE41266804500C05633 /* ZoomingScrollView.h */; - name = "ZoomingScrollView.h: 36"; - rLen = 0; - rLoc = 733; - rType = 0; - vrLen = 875; - vrLoc = 0; - }; - 4C667C5A1270C8370008B630 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 4CC82BE51266804500C05633 /* ZoomingScrollView.m */; - name = "ZoomingScrollView.m: 105"; - rLen = 0; - rLoc = 2627; - rType = 0; - vrLen = 1643; - vrLoc = 1603; - }; 4C667C5D1270C8EC0008B630 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 4C667B2B1270AFCE0008B630 /* Menu.h */; @@ -304,26 +391,6 @@ vrLen = 209; vrLoc = 0; }; - 4C667C5E1270C8EC0008B630 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 1D3623240D0F684500981E51 /* MWPhotoBrowserAppDelegate.h */; - name = "MWPhotoBrowserAppDelegate.h: 19"; - rLen = 0; - rLoc = 342; - rType = 0; - vrLen = 342; - vrLoc = 0; - }; - 4C667C601270C8EC0008B630 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 4C75D46E126B659A004D0ECF /* MWPhoto.m */; - name = "MWPhoto.m: 114"; - rLen = 0; - rLoc = 2417; - rType = 0; - vrLen = 2295; - vrLoc = 1342; - }; 4C667C6E1270CA3A0008B630 /* PBXBookmark */ = { isa = PBXBookmark; fRef = 4C667C411270C6A50008B630 /* UIBarButtonItemArrowLeft.png */; @@ -332,60 +399,10 @@ isa = PBXBookmark; fRef = 4C667C421270C6A50008B630 /* UIBarButtonItemArrowLeft@2x.png */; }; - 4C667CAB1270CF150008B630 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 4C667B2C1270AFCE0008B630 /* Menu.m */; - name = "Menu.m: 34"; - rLen = 0; - rLoc = 644; - rType = 0; - vrLen = 2216; - vrLoc = 33; - }; - 4C667CAC1270CF150008B630 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 28D7ACF60DDB3853001CB0EB /* MWPhotoBrowser.h */; - name = "MWPhotoBrowser.h: 30"; - rLen = 0; - rLoc = 572; - rType = 0; - vrLen = 1571; - vrLoc = 0; - }; - 4C667CB41270D1230008B630 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 28D7ACF70DDB3853001CB0EB /* MWPhotoBrowser.m */; - name = "MWPhotoBrowser.m: 1"; - rLen = 0; - rLoc = 0; - rType = 0; - vrLen = 1823; - vrLoc = 0; - }; 4C667CB51270D1230008B630 /* PBXBookmark */ = { isa = PBXBookmark; fRef = 4CFB7931126A3B4100E5F263 /* photo1l.jpg */; }; - 4C667CB61270D1230008B630 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 1D3623250D0F684500981E51 /* MWPhotoBrowserAppDelegate.m */; - name = "MWPhotoBrowserAppDelegate.m: 21"; - rLen = 0; - rLoc = 469; - rType = 0; - vrLen = 2237; - vrLoc = 0; - }; - 4C667CBC1270D4560008B630 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 4C667B2C1270AFCE0008B630 /* Menu.m */; - name = "Menu.m: 1"; - rLen = 0; - rLoc = 0; - rType = 0; - vrLen = 1562; - vrLoc = 0; - }; 4C75D46D126B659A004D0ECF /* MWPhoto.h */ = { uiCtxt = { sepNavIntBoundsRect = "{{0, 0}, {1474, 1057}}"; @@ -395,9 +412,9 @@ }; 4C75D46E126B659A004D0ECF /* MWPhoto.m */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1859, 2366}}"; - sepNavSelRange = "{1606, 0}"; - sepNavVisRange = "{1343, 1546}"; + sepNavIntBoundsRect = "{{0, 0}, {994, 2197}}"; + sepNavSelRange = "{2964, 74}"; + sepNavVisRange = "{2141, 1700}"; }; }; 4C75D4A3126B7ABF004D0ECF /* PlistBookmark */ = { @@ -418,7 +435,7 @@ argumentStrings = ( ); autoAttachOnCrash = 1; - breakpointsEnabled = 0; + breakpointsEnabled = 1; configStateDict = { }; customDataFormattersEnabled = 1; @@ -459,16 +476,16 @@ }; 4CC82BE41266804500C05633 /* ZoomingScrollView.h */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1474, 1057}}"; - sepNavSelRange = "{733, 0}"; + sepNavIntBoundsRect = "{{0, 0}, {994, 760}}"; + sepNavSelRange = "{539, 0}"; sepNavVisRange = "{0, 875}"; }; }; 4CC82BE51266804500C05633 /* ZoomingScrollView.m */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1474, 3341}}"; - sepNavSelRange = "{2627, 0}"; - sepNavVisRange = "{1603, 1643}"; + sepNavIntBoundsRect = "{{0, 0}, {1186, 3549}}"; + sepNavSelRange = "{1900, 0}"; + sepNavVisRange = "{1729, 859}"; }; }; 4CFB783C126A29BE00E5F263 /* UIImageViewTap.h */ = { diff --git a/MWPhotoBrowser.xcodeproj/project.pbxproj b/MWPhotoBrowser.xcodeproj/project.pbxproj index 3939257..92bd76e 100755 --- a/MWPhotoBrowser.xcodeproj/project.pbxproj +++ b/MWPhotoBrowser.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; }; 28D7ACF80DDB3853001CB0EB /* MWPhotoBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* MWPhotoBrowser.m */; }; + 4C4156C61277301E00C96767 /* MainWindow-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C4156C51277301E00C96767 /* MainWindow-iPad.xib */; }; 4C48EFCD126F8DD900F85546 /* UIImage+Decompress.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C48EFCC126F8DD900F85546 /* UIImage+Decompress.m */; }; 4C48EFD2126F90B100F85546 /* UIViewTap.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C48EFD1126F90B100F85546 /* UIViewTap.m */; }; 4C667B2D1270AFCE0008B630 /* Menu.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C667B2C1270AFCE0008B630 /* Menu.m */; }; @@ -46,6 +47,7 @@ 28D7ACF70DDB3853001CB0EB /* MWPhotoBrowser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWPhotoBrowser.m; sourceTree = ""; }; 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 32CA4F630368D1EE00C91783 /* MWPhotoBrowser_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWPhotoBrowser_Prefix.pch; sourceTree = ""; }; + 4C4156C51277301E00C96767 /* MainWindow-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "MainWindow-iPad.xib"; path = "Resources-iPad/MainWindow-iPad.xib"; sourceTree = ""; }; 4C48EFCB126F8DD900F85546 /* UIImage+Decompress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Decompress.h"; sourceTree = ""; }; 4C48EFCC126F8DD900F85546 /* UIImage+Decompress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Decompress.m"; sourceTree = ""; }; 4C48EFD0126F90B100F85546 /* UIViewTap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIViewTap.h; sourceTree = ""; }; @@ -112,6 +114,7 @@ 080E96DDFE201D6D7F000001 /* Classes */, 4C667CB31270D0E50008B630 /* Photos */, 29B97317FDCFA39411CA2CEA /* Resources */, + 4C4156C41277301D00C96767 /* Resources-iPad */, 29B97315FDCFA39411CA2CEA /* Other Sources */, 29B97323FDCFA39411CA2CEA /* Frameworks */, 19C28FACFE9D520D11CA2CBB /* Products */, @@ -151,6 +154,14 @@ name = Frameworks; sourceTree = ""; }; + 4C4156C41277301D00C96767 /* Resources-iPad */ = { + isa = PBXGroup; + children = ( + 4C4156C51277301E00C96767 /* MainWindow-iPad.xib */, + ); + name = "Resources-iPad"; + sourceTree = ""; + }; 4C48EFD3126F90C600F85546 /* Categories */ = { isa = PBXGroup; children = ( @@ -273,6 +284,7 @@ 4C667C461270C6A50008B630 /* UIBarButtonItemArrowLeft@2x.png in Resources */, 4C667C471270C6A50008B630 /* UIBarButtonItemArrowRight.png in Resources */, 4C667C481270C6A50008B630 /* UIBarButtonItemArrowRight@2x.png in Resources */, + 4C4156C61277301E00C96767 /* MainWindow-iPad.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -302,6 +314,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -310,6 +323,8 @@ INFOPLIST_FILE = "MWPhotoBrowser-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 3.0; PRODUCT_NAME = MWPhotoBrowser; + SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -317,12 +332,15 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; COPY_PHASE_STRIP = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = MWPhotoBrowser_Prefix.pch; INFOPLIST_FILE = "MWPhotoBrowser-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 3.0; PRODUCT_NAME = MWPhotoBrowser; + SDKROOT = iphoneos4.1; + TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; name = Release; diff --git a/README.markdown b/README.markdown index 3faecc8..7820ac2 100644 --- a/README.markdown +++ b/README.markdown @@ -21,6 +21,12 @@ See the code snippet below for an example of how to implement the photo browser. MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithPhotos:photos]; [self.navigationController pushViewController:browser animated:YES]; +If desired, you can choose which photo is displayed first: + + // Create & present browser + MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithPhotos:photos]; + [browser setInitialPageIndex:2]; // Show second page first + [self.navigationController pushViewController:browser animated:YES]; ## Adding to your project diff --git a/Resources-iPad/MainWindow-iPad.xib b/Resources-iPad/MainWindow-iPad.xib new file mode 100644 index 0000000..2515fb8 --- /dev/null +++ b/Resources-iPad/MainWindow-iPad.xib @@ -0,0 +1,393 @@ + + + + 800 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 123 + + + YES + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + IBIPadFramework + + + + 292 + {768, 1004} + + 1 + MSAxIDEAA + + NO + NO + + 2 + + IBIPadFramework + YES + + + + + YES + + + delegate + + + + 4 + + + + window + + + + 14 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + 3 + + + MWPhotoBrowser App Delegate + + + -2 + + + + + 12 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 12.IBEditorWindowLastContentRect + 12.IBLastUsedUIStatusBarStylesToTargetRuntimesMap + 12.IBPluginDependency + 3.CustomClassName + 3.IBPluginDependency + + + YES + UIApplication + UIResponder + {{525, 346}, {320, 480}} + + IBCocoaTouchFramework + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + MWPhotoBrowserAppDelegate + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 15 + + + + YES + + MWPhotoBrowserAppDelegate + NSObject + + window + UIWindow + + + window + + window + UIWindow + + + + IBProjectSource + Classes/MWPhotoBrowserAppDelegate.h + + + + MWPhotoBrowserAppDelegate + NSObject + + IBUserSource + + + + + UIWindow + UIView + + IBUserSource + + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIApplication + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIApplication.h + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + UIWindow + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIWindow.h + + + + + 0 + IBIPadFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + MWPhotoBrowser.xcodeproj + 3 + 123 + +