Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 40    Views: 289

Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
08/04/12 02:14 PM (13 years ago)

iOS Tutorial - how to create a social image gallery

I posted this yesterday in this thread - http://www.buzztouch.com/forum/thread.php - but I figured I'd make another thread about it since I think it can be an extremely effective way of driving more traffic towards your app. Following this tutorial will add a socialize action bar to the bottom of your image gallery that looks like this - http://www.pixobit.com/wp-content/uploads/2012/08/Screen-shot-at-2012-08-04-0.30.39-AM.png - each image will have it's own individual bar with different comments, views, etc... 1. Go to http://www.getsocialize.com and create an account 2. After clicking on the confirmation link in your email, you will be taken to this screen - http://www.pixobit.com/wp-content/uploads/2012/08/socializescreen.png - click the "download SDK for iOS" button to download the SDK, then click "Add a new app" - follow the instructions closely on the "Add an Application" screen to create your socialize app. 3. Go to this page - http://socialize.github.com/socialize-sdk-ios/getting_started.html#getting-started-guide -and closely follow STEPS 1-4 ONLY then continue with the following steps 4. Add the following line to your viewcontroller.h #import <Socialize/Socialize.h> 5. Add the following lines of code to BT_Screen_images.h - example placement is displayed in this screenshot - http://www.pixobit.com/wp-content/uploads/2012/08/Screen-shot-at-2012-08-04-0.22.33-AM.png NSString *socializePic; @property (nonatomic, retain) NSString *socializePic; @property (nonatomic, retain) SZActionBar *actionBar; @property (nonatomic, retain) id<SZEntity> entity; 6. In BT_Screen_images.m, scroll about 3/4 of the way down until you find the following chunk of code - //updates navigation -(void)updateNavigation { //figure out the title in the navigation bar... NSString *tmpTitle; if([[BT_strings getJsonPropertyValue:self.screenData.jsonVars:@"showCountInNavBar":@"0"] isEqualToString:@"1"]){ tmpTitle = [NSString stringWithFormat:@"%i of %i", (currentPageIndex + 1), [self.photos count]]; }else{ tmpTitle = [BT_strings getJsonPropertyValue:self.screenData.jsonVars:@"navBarTitleText":@""]; } self.title = tmpTitle; //figure out the image's title (assume we don't have one)... BT_item *thisImage = [self.imageList objectAtIndex:currentPageIndex]; [self.titleLabel setText:@""]; [self.titleBox setHidden:TRUE]; if([thisImage.jsonVars objectForKey:@"imageTitle"]){ if([[thisImage.jsonVars objectForKey:@"imageTitle"] length] > 1){ [self.titleLabel setText:[thisImage.jsonVars objectForKey:@"imageTitle"]]; [self.titleBox setHidden:FALSE]; 7. Add the following code directly after the code shown above - example placement is displayed in this screenshot - http://www.pixobit.com/wp-content/uploads/2012/08/sdsd.png socializePic = [thisImage.jsonVars objectForKey:@"imageURL"]; self.entity = [SZEntity entityWithKey:socializePic name:socializePic]; self.actionBar = [SZActionBar defaultActionBarWithFrame:CGRectNull entity:self.entity viewController:self]; //add save image button to action bar SZActionButton *saveButton = [SZActionButton actionButtonWithIcon:nil title:@"Save"]; saveButton.actionBlock = ^(SZActionButton *button, SZActionBar *bar) { UIImage *image = [self imageAtIndex:currentPageIndex]; UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); }; //add refresh button to action bar SZActionButton *refreshButton = [SZActionButton actionButtonWithIcon:[UIImage imageNamed:@"refresh_white.png"] title:nil]; { refreshButton.actionBlock = ^(SZActionButton *button, SZActionBar *bar) { for(BT_zoomingScrollView *page in visiblePages) { [page removeFromSuperview]; } [self downloadData]; }; self.actionBar.itemsLeft = [NSArray arrayWithObjects:[SZActionButton viewsButton], refreshButton, saveButton, nil]; [self.view addSubview:self.actionBar]; That should do it - launch the app in the simulator and go to your image gallery. You will hopefully see the action bar displayed in the image gallery Since the action bar is called when the navigation display changes, a new entity/action bar will load with the image url when you swipe left or right to the next/previous image I'm not a coding pro by any means so I may be overcomplicating it, but it does definitely work - if anybody isn't getting it let me know, hopefully I'll be able to help If you don't want any of the extra buttons on the action bar just replace step seven with this code - socializePic = [thisImage.jsonVars objectForKey:@"imageURL"]; self.entity = [SZEntity entityWithKey:socializePic name:socializePic]; self.actionBar = [SZActionBar defaultActionBarWithFrame:CGRectNull entity:self.entity viewController:self]; [self.view addSubview:self.actionBar];
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
08/04/12 02:24 PM (13 years ago)
By the way, adding Facebook and Twitter functionality is very simple - For the Facebook guide go here - http://socialize.github.com/socialize-sdk-ios/facebook.html - only follow the guide for standard Facebook integration - ignore the "Linking with Existing Facebook Credentials" guide and everything after it For the Twitter guide go here - http://socialize.github.com/socialize-sdk-ios/twitter.html - only follow the guide for standard Twitter integration - ignore the "Linking to Twitter Using Existing Credentials" guide and everything after it
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
08/04/12 02:43 PM (13 years ago)
Would this work with html docs too?
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
08/04/12 02:54 PM (13 years ago)
Excellent Fred
 
sydidd apps
Aspiring developer
Profile
Posts: 15
Reg: Jan 26, 2012
Sydney
1,600
like
08/04/12 03:20 PM (13 years ago)
edit
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
08/04/12 03:20 PM (13 years ago)
@Absentia huge props for creating and sharing this tutorial! Would anyone be willing to PDF this tutorial? Cheers, David buzztouchmods.com
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
08/04/12 03:43 PM (13 years ago)
Thanks guys...I forgot to mention - it is probably a good idea to hide the image gallery status bar via your buzztouch control panel. Otherwise while the gallery is loading you will see the standard buzztouch status bar for a couple seconds before it is replaced by the action bar @mutzy, You can make pretty much anything into a socialize entity as long as you can find a unique identifier for the entitykey and entityname. For a lot of screens, simply using the navigation bar text works great --- socializePic = [NSString stringWithFormat:@"%@", [BT_strings getJsonPropertyValue:screenData.jsonVars:@"navBarTitleText":@""]]; self.entity = [SZEntity entityWithKey:socializePic name:socializePic]; self.actionBar = [SZActionBar defaultActionBarWithFrame:CGRectNull entity:self.entity viewController:self]; [self.view addSubview:self.actionBar];
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
08/04/12 04:58 PM (13 years ago)
Awesome. Looks like a nice feature, but an even better implementation of it. Perfect spot for Socialize - the image gallery. Can't wait to add that to my image gallery. I'll give it a shot with the 2.0 SH code and report back one of these days. Does that bar stretch when you rotate the screen? And is that your 1D App featured on their home page? Nice work man, you are just destroying it with this code. Still trying to catch up with the action sheet code stuff you were discussing with David. Have you looked at Appoxee yet? Thanks again for the code share/tutorial!! Excellent use of Socialize.
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
08/04/12 05:07 PM (13 years ago)
Haha no that isn't my 1D app - I noticed it yesterday though. Looks like I need to catch up with the competition! I just submitted the update that includes this feature yesterday I haven't checked out appoxee - socialize actually has a push notification feature as well, but I haven't figured out how to successfully implement it. I also haven't tested out socialize yet with an app that allows rotation - I would imagine it rotates and stretches but I can't say for sure
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
08/04/12 05:21 PM (13 years ago)
This is great. Thanks for posting. I did a similar thing in my football app. Slightly different approach but same results. Great job.
 
Black White
I hate code!
Profile
Posts: 292
Reg: Feb 22, 2012
hanoi
4,770
like
08/04/12 06:35 PM (13 years ago)
good job, but try to make PDF tutorial perfect code + images is better im Hoang
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
08/04/12 06:38 PM (13 years ago)
I would - I don't really have the resources or know-how to make pdf files. If anybody else wants to make one feel free
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
08/05/12 11:34 AM (13 years ago)
This is huge!!! Thank you!!!! I'll post a video and a PDF soon!
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
08/05/12 04:18 PM (13 years ago)
Is there a value that we are supposed to use for these lines? "@property (nonatomic, retain) SZActionBar *actionBar; @property (nonatomic, retain) id<SZEntity> entity; " ...is this tutorial assuming that you have a Image Gallery already built in the app? Thank you
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
08/05/12 04:20 PM (13 years ago)
I guess this is my question here.... You can make pretty much anything into a socialize entity as long as you can find a unique identifier for the entitykey and entityname. For a lot of screens, simply using the navigation bar text works great --- How do I do this, meaning is there some docs online you can direct me to? Thanks
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
08/05/12 04:56 PM (13 years ago)
I guess this is my question here.... You can make pretty much anything into a socialize entity as long as you can find a unique identifier for the entitykey and entityname. For a lot of screens, simply using the navigation bar text works great --- How do I do this, meaning is there some docs online you can direct me to? Thanks
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
08/06/12 07:33 AM (13 years ago)
Again this is awesome, will be implementing it this week in my 2.0 Gallery. Many Thanks! -as for PDF's - Doesn't the MAC/OSX do this natively? If you make a doc in TEXTEDIT you get a File/Save as PDF option. and for Windows look at PDF Creator, free and easy.
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
08/06/12 08:45 AM (13 years ago)
@ATRAIN53 yes OS X does this natively. I tried to implement this last night but there seems to be a piece that I am missing. I get to step 3 (that is the first 4 steps on Socialize's website) and don't have any problems.....then after I finish with step 7 it fails. Any ideas? I think the problem is within this section below as I don't fully understand it.... "you can make pretty much anything into a socialize entity as long as you can find a unique identifier for the entitykey and entityname. For a lot of screens, simply using the navigation bar text works great ---" socializePic = [NSString stringWithFormat:@"%@", [BT_strings getJsonPropertyValue:screenData.jsonVars:@"navBarTitleText":@""]]; self.entity = [SZEntity entityWithKey:socializePic name:socializePic]; self.actionBar = [SZActionBar defaultActionBarWithFrame:CGRectNull entity:self.entity viewController:self]; [self.view addSubview:self.actionBar]; Just need a little helping hand here and then I will make they video (much easier for me to learn this way) and PDF. Thank you
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
08/06/12 10:11 AM (13 years ago)
Follow steps 1-5 (for step 5 the screen doesn't have to be images.h - it can be any screen.h you want) - for step 6 paste this code inside of the "view will appear" method of the screen.m file- socializePic = [NSString stringWithFormat:@"%@", [BT_strings getJsonPropertyValue:screenData.jsonVars:@"navBarTitleText":@""]]; self.entity = [SZEntity entityWithKey:socializePic name:socializePic]; self.actionBar = [SZActionBar defaultActionBarWithFrame:CGRectNull entity:self.entity viewController:self]; [self.view addSubview:self.actionBar];
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
08/06/12 11:04 AM (13 years ago)
WOW! So simple for me to have missed! Thank you!!! All I need to do is just copy and paste that in the .m file where I want it to appear....I will post back as soon as I get it going!
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
08/06/12 11:27 AM (13 years ago)
Is there anything we have to do on the socialize website or will the entities populate themselves as they're used?
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
08/06/12 11:36 AM (13 years ago)
Is there anything we have to do on the socialize website or will the entities populate themselves as they're used?
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
08/06/12 11:48 AM (13 years ago)
I ask this because I followed the instructions above for the image gallery screens, my app runs fine, but there's no socialize bar. When I go to the socialize website it says "You have yet to use our API or SDK to authenticate your app with our system." so I feel I am missing something. Josh
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
08/06/12 01:44 PM (13 years ago)
My only guess would be that you don't have the correct Consumer Secret and Consumer Private oAuth keys in your appdelegate.m
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
08/06/12 01:55 PM (13 years ago)
I've triple checked, my secret and oAuth keys are correct. My app is ver 1.5, does that make a difference? I'll just start from scratch tomorrow, I probably did something stupid.
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
08/06/12 02:27 PM (13 years ago)
Has anybody else gotten it working?
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
08/06/12 08:16 PM (13 years ago)
I am very close....this is the only line of code that is causing a problem. "socializePic = [thisImage.jsonVars objectForKey:@"http://homerhart.com/files/-hh_icon_website_114.png"]; Use of undeclared identifier 'thisImage' is the error. If I comment that out I can build with no errors
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
08/07/12 12:42 AM (13 years ago)
that's strange - if you're putting that line of code directly under the code shown in step 6, that shouldn't be happening. 'thisImage' is declared in the same method just a few lines up where it says BT_item *thisImage = [self.imageList objectAtIndex:currentPageIndex]; Also, is there a reason you are typing out the entire url? Using the line '[thisImage.jsonVars objectForKey:@"imageURL"]' will automatically retreive the url of whatever image is being shown in the gallery. If you are going to use the whole url you could just do this - self.entity = [SZEntity entityWithKey:@"http://homerhart.com/files/-hh_icon_website_114.png" name:@"http://homerhart.com/files/-hh_icon_website_114.png"]; self.actionBar = [SZActionBar defaultActionBarWithFrame:CGRectNull entity:self.entity viewController:self]; [self.view addSubview:self.actionBar];
 
ALFREA
Aspiring developer
Profile
Posts: 89
Reg: Jul 24, 2011
San Antonio, TX
3,640
like
08/09/12 02:31 PM (13 years ago)
@mutzy Did you get it to work? I'm thinking about using this on a 1.5 version.
 
ALFREA
Aspiring developer
Profile
Posts: 89
Reg: Jul 24, 2011
San Antonio, TX
3,640
like
08/09/12 02:36 PM (13 years ago)
edit: double submit
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
08/10/12 08:04 AM (13 years ago)
@Absentia Was able to copy all code and added my oAuth Keys... I can compile without any errors. I do get 6 Semantic Issues. ~ property 'actionBar' requires method 'actionBar' to be defined - use @synthesize, @dynamic or provide a method implementation in this class implementation @implementation BT_screen_images I get this same error for these other 5 properties SetActionBar, socializePic, setSocializePic, entity, and setEntity. Thank you for your help again!!!! PS: My previous error was cleared by adding a extra closed curly brace on step 7.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
08/10/12 01:02 PM (13 years ago)
I'm getting close on 2.0 Self Hosted with a Flickr Gallery. App is compiling but crashing after I report to cloud with this error. *** Assertion failure in -[SocializeConfiguration initWithWithConfigurationPath:], /Users/griswold/ios/socialize-sdk-ios-private/socialize-sdk-ios/Socialize-noarc/SocializeConfiguration.m:69 (Griswold? Clark?)
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
08/10/12 07:34 PM (13 years ago)
Started over from scratch... still no luck. I can get it to build fine but there is no action bar. Has ANYONE gotten this to work using the above directions??? I'm on ver 1.5.
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
08/10/12 07:58 PM (13 years ago)
Not yet...still here @Absentia Was able to copy all code and added my oAuth Keys... I can compile without any errors. I do get 6 Semantic Issues. ~ property 'actionBar' requires method 'actionBar' to be defined - use @synthesize, @dynamic or provide a method implementation in this class implementation @implementation BT_screen_images I get this same error for these other 5 properties SetActionBar, socializePic, setSocializePic, entity, and setEntity. Thank you for your help again!!!!
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
11/21/12 02:08 PM (13 years ago)
Thanks again for this tutorial @Absentia .. It was easy to implement. I hadn't used it since version 1.7.4.. my memory had slipped since then. works great with the gallery as well. good stuff
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
11/21/12 02:28 PM (13 years ago)
Cool...glad it worked out for you - I just scanned over it and realized I deleted some of the images I linked to :/ but I guess they weren't really necessary anyway. I have recently started doing one thing slightly different than what the tutorial says. I now put the socialize code in the images.m file directly after this line - //figure out the image's title (assume we don't have one)... BT_item *thisImage = [self.imageList objectAtIndex:currentPageIndex]; putting it after [self.titleBox setHidden:FALSE]; , as I said to do in the original tutorial, was causing some issues with the bar randomly not showing
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
11/21/12 02:37 PM (13 years ago)
ah, ive just submitted. on the next update before christmas i'll have a reason to update again. one question: i would like to figure out how to get the subject line of the share via email to not contain the gallery image url. once i get a breather from this app, i will check into and report back thanks again!
 
AppOne
buzztouch Evangelist
Profile
Posts: 348
Reg: Apr 03, 2012
London
13,980
like
12/23/12 02:15 PM (13 years ago)
Hi, been trying this social image gallery tutorial on a BT v2.0 using Mac Image Gallery plugin. I'm getting a persistent error that reads use of undeclared identifier 'jumpToPageAtIndex' at: //jump to page index -(void)jumpToPageAtIndex:(int)index { (ps. when, as an experiment, I delete this bit and ran the app it booted in but then under my revmob fullscreen ad there was just a black screen) Any ideas anyone?
 
AppOne
buzztouch Evangelist
Profile
Posts: 348
Reg: Apr 03, 2012
London
13,980
like
12/23/12 02:15 PM (13 years ago)
There were no clues in the output, just: 2012-12-23 20:45:48.944 quizthewalkingdeadedition[84507:c07] [RevMob] Starting RevMobAds 2012-12-23 20:45:49.241 quizthewalkingdeadedition[84507:c07] [RevMob] Initializing Fullscreen. 2012-12-23 20:45:49.259 quizthewalkingdeadedition[84507:c07] Socialize Warning: Facebook is not configured. Facebook UI controls will not be shown. You should consider enabling Socialize's Facebook support, as described in http://socialize.github.com/socialize-sdk-ios/getting_started.html 2012-12-23 20:45:51.810 quizthewalkingdeadedition[84507:c07] [RevMob] Ad received: (200). 2012-12-23 20:45:58.256 quizthewalkingdeadedition[84507:c07] [RevMob] Fullscreen closed. 2012-12-23 20:45:58.257 quizthewalkingdeadedition[84507:c07] [RevMob] Dealloc RevMobFullscreen
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
01/10/13 05:02 PM (13 years ago)
Hey AppOneBeta - I'm just now seeing your post...did you ever get it figured out?
 
AppOne
buzztouch Evangelist
Profile
Posts: 348
Reg: Apr 03, 2012
London
13,980
like
01/23/13 01:04 AM (13 years ago)
Hi Absentia - no I implemented another tutorial (which isn't so good for image gallery) but will tackle it again for next update!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.