Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Syntax color #78

Closed
wants to merge 2 commits into from

2 participants

@rodowi

Some syntax color won't hurt (Improves readability)

  • Adds obj-c syntax color to code snippets
@mwaterfall
Owner

Apologies for the late reply. Good suggestion ;-) Will get that done!

@mwaterfall mwaterfall closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 14, 2012
  1. @rodowi
  2. @rodowi

    Less tabs more action

    rodowi authored
    Removes extra tab on each row of code snippets
This page is out of date. Refresh to see the latest.
Showing with 38 additions and 31 deletions.
  1. +38 −31 README.markdown
View
69 README.markdown
@@ -21,32 +21,36 @@ MWPhotoBrowser is designed to be presented within a navigation controller. Simpl
See the code snippet below for an example of how to implement the photo browser. There is also a simple demo app within the project.
- // Create array of `MWPhoto` objects
- self.photos = [NSMutableArray array];
- [photos addObject:[MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"photo2l" ofType:@"jpg"]]];
- [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3629/3339128908_7aecabc34b.jpg"]]];
- [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3590/3329114220_5fbc5bc92b.jpg"]]];
-
- // Create & present browser
- MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
- // Set options
- browser.wantsFullScreenLayout = YES; // Decide if you want the photo browser full screen, i.e. whether the status bar is affected (defaults to YES)
- browser.displayActionButton = YES; // Show action button to save, copy or email photos (defaults to NO)
- [browser setInitialPageIndex:1]; // Example: allows second image to be presented first
- // Present
- [self.navigationController pushViewController:browser animated:YES];
+```obj-c
+// Create array of `MWPhoto` objects
+self.photos = [NSMutableArray array];
+[photos addObject:[MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"photo2l" ofType:@"jpg"]]];
+[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3629/3339128908_7aecabc34b.jpg"]]];
+[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3590/3329114220_5fbc5bc92b.jpg"]]];
+
+// Create & present browser
+MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
+// Set options
+browser.wantsFullScreenLayout = YES; // Decide if you want the photo browser full screen, i.e. whether the status bar is affected (defaults to YES)
+browser.displayActionButton = YES; // Show action button to save, copy or email photos (defaults to NO)
+[browser setInitialPageIndex:1]; // Example: allows second image to be presented first
+// Present
+[self.navigationController pushViewController:browser animated:YES];
+```
Then respond to the required delegate methods:
- - (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
- return self.photos.count;
- }
+```obj-c
+- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
+ return self.photos.count;
+}
- - (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
- if (index < self.photos.count)
- return [self.photos objectAtIndex:index];
- return nil;
- }
+- (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
+ if (index < self.photos.count)
+ return [self.photos objectAtIndex:index];
+ return nil;
+}
+```
You can present the browser modally simply by wrapping it in a new navigation controller and presenting that. The demo app allows you to toggle between the two presentation types.
@@ -57,8 +61,10 @@ If you don't want to view the photo browser full screen (for example if you are
Photo captions can be displayed simply by setting the `caption` property on specific photos:
- MWPhoto *photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"photo2l" ofType:@"jpg"]];
- photo.caption = @"Campervan";
+```obj-c
+MWPhoto *photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"photo2l" ofType:@"jpg"]];
+photo.caption = @"Campervan";
+```
No caption will be displayed if the caption property is not set.
@@ -73,12 +79,13 @@ By default, the caption is a simple black transparent view with a label displayi
Example delegate method for custom caption view:
- - (MWCaptionView *)photoBrowser:(MWPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index {
- MWPhoto *photo = [self.photos objectAtIndex:index];
- MyMWCaptionViewSubclass *captionView = [[MyMWCaptionViewSubclass alloc] initWithPhoto:photo];
- return [captionView autorelease];
- }
-
+```obj-c
+- (MWCaptionView *)photoBrowser:(MWPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index {
+ MWPhoto *photo = [self.photos objectAtIndex:index];
+ MyMWCaptionViewSubclass *captionView = [[MyMWCaptionViewSubclass alloc] initWithPhoto:photo];
+ return [captionView autorelease];
+}
+```
## Adding to your project (Xcode 4)
@@ -141,4 +148,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE.
Something went wrong with that request. Please try again.