Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 20    Views: 79

mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
06/12/13 12:22 AM (12 years ago)

Hide Scringo like button at certain point?

Anyone have an idea on how I could tell the Scringo like button to hide at a certain point. I'm using it in the bta_thumbviewer plugin using this code, but I need it to disappear when I leave the photo and go back to the "see all" screen with the thumbnails. I've been trying with no luck. //appDelegate screenshot_appDelegate *appDelegate = (screenshot_appDelegate *)[[UIApplication sharedApplication] delegate]; NSString *likeIt = [_photoSource photoGallery:self urlForPhotoSize:FGalleryPhotoSizeFullsize atIndex:index]; ScringoLikeButton *likeButton = [[ScringoLikeButton alloc] initWithFrame:CGRectMake(40, 300, 50, 27)]; UIBarButtonItem *likeItButton = [[UIBarButtonItem alloc] initWithCustomView:likeButton]; //UNCOMMENT FOR TAB BAR LAYOUT ((UINavigationController*)[appDelegate.rootApp.rootTabBarController.viewControllers objectAtIndex: 0]).navigationBar.topItem.RightBarButtonItem = likeItButton; //UNCOMMENT FOR NON TAB BAR LAYOUT /*((UINavigationController*)[appDelegate.rootApp.rootNavController.retain retain ]).navigationBar.topItem.rightBarButtonItems = [NSArray arrayWithObjects:[ScringoAgent scringoActivationBarItem], likeItButton, nil]; */ [likeButton updateLikeObject:likeIt type:SCRINGO_APP_LIKE_IMAGE description:@"a Screenshot!"];
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
06/12/13 05:08 AM (12 years ago)
Hi mleonard, I think I have the solution and was hoping you are willing to test. I optimized your code a bit (at least for the TAB BAR LAYOUT) so you don't have to choose what index you tab is. Next to this it now uses the title (caption) of the image as the 'liked' text. So here we go: Make your loadFullsizeImageWithIndex (around line 1127) look like this: - (void)loadFullsizeImageWithIndex:(NSUInteger)index { FGalleryPhoto *photo = [_photoLoaders objectForKey:[NSString stringWithFormat:@"%i", index]]; if( photo == nil ) photo = [self createGalleryPhotoForIndex:index]; [photo loadFullsize]; plugins_appDelegate *appDelegate = (plugins_appDelegate *)[[UIApplication sharedApplication] delegate]; NSString *likeIt = [_photoSource photoGallery:self urlForPhotoSize:FGalleryPhotoSizeFullsize atIndex:index]; //set the image caption name as the subject NSString *thePhotoTitle = [_photoSource photoGallery:self captionForPhotoAtIndex:_currentIndex]; ScringoLikeButton *likeButton = [[ScringoLikeButton alloc] initWithFrame:CGRectMake(40, 300, 50, 27)]; UIBarButtonItem *likeItButton = [[UIBarButtonItem alloc] initWithCustomView:likeButton]; int selectedTab = 0; if([appDelegate.rootApp.tabs count] > 0){ selectedTab = [appDelegate.rootApp.rootTabBarController selectedIndex]; ((UINavigationController*)[appDelegate.rootApp.rootTabBarController.viewControllers objectAtIndex: selectedTab]).navigationBar.topItem.leftBarButtonItem = likeItButton; } [likeButton updateLikeObject:likeIt type:SCRINGO_APP_LIKE_IMAGE description:thePhotoTitle]; } Now look for showThumbnailViewWithAnimation (around line 971) and make it look like this: - (void)showThumbnailViewWithAnimation:(BOOL)animation { _isThumbViewShowing = YES; [self arrangeThumbs]; [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"1 by 1", @"")]; self.navigationItem.hidesBackButton = NO; [self.navigationItem setLeftBarButtonItem:nil animated:NO]; if (animation) { // do curl animation [UIView beginAnimations:@"uncurl" context:nil]; [UIView setAnimationDuration:.666]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:_thumbsView cache:YES]; [_thumbsView setHidden:NO]; [UIView commitAnimations]; } else { [_thumbsView setHidden:NO]; } } That's it and I tested it and as far as I can tell it works. Love to hear your experience. Best Regards, Danny
 
mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
like
06/12/13 08:51 AM (12 years ago)
Hey @PSMDanny, Thanks! Yep it's working for me too. I've been racking my brain trying to get this to work, so thanks a lot! I'm not much of a programmer so it's trial and error for me...
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
06/12/13 12:57 PM (12 years ago)
Great to hear!! Only thing that isn't complete is when you start the images in full screen. The first full image doesn't get the scringo like button..... Maybe find a solution some day but I think for now this will help a lot of users that will integrate scringo into their apps. Best Regards, Danny
 
mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
like
06/12/13 01:14 PM (12 years ago)
Yeah I noticed that too. I'm okay with it for now! Glad to have it working.
 
mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
like
06/13/13 12:12 AM (12 years ago)
The only other thing I have found is that if i click on a photo and then go to email it, once I exit the email, I am back at the thumbnail view and the like button is covering up the back button. Once you click "1 by 1" and "see all" it's gone again. Not a huge deal, but just something to take note on.
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
06/13/13 02:33 AM (12 years ago)
Ok Thanks, Good to know and if I'm able to find a fix for this I'll post it here. Best Regards, Danny
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
06/13/13 03:27 AM (12 years ago)
Hi, To solve the problem when you close the email add this line (around line 444 in mailComposeController): [self.navigationItem setLeftBarButtonItem:nil animated:NO]; right after this: [self.navigationController dismissViewControllerAnimated:TRUE completion:nil]; So the complete methode (mailComposeController looks like this: - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { switch (result) { case MFMailComposeResultCancelled: NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued."); break; case MFMailComposeResultSaved: NSLog(@"Mail saved: you saved the email message in the drafts folder."); break; case MFMailComposeResultSent: NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send."); break; case MFMailComposeResultFailed: NSLog(@"Mail failed: the email message was not saved or queued, possibly due to an error."); break; default: NSLog(@"Mail not sent."); break; } // Remove the mail view [self.navigationController dismissViewControllerAnimated:TRUE completion:nil]; [self.navigationItem setLeftBarButtonItem:nil animated:NO]; } Hope this helps. Best Regards, Danny
 
mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
like
06/13/13 09:11 AM (12 years ago)
Ok, that fixed it! Unrelated to Scringo, but something else I was wondering. Do you know what I could add to enable the scroll the to top when the status bar is tapped? Maybe this somewhere? scrollView.scrollsToTop = YES;
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
06/13/13 09:42 AM (12 years ago)
Hi mleonard, Sorry to say that I don't understand what you are asking?? Best Regards, Danny
 
mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
like
06/13/13 09:46 AM (12 years ago)
Sorry, I should have explained better! Usually in a scrollview, when you tap the status bar, the view automatically scrolls to the top. For example, in the mail app. Scroll down, then tap the status bar and it will scroll to the top. I'm adding a few hundred photos to the thumbnail scroll view, so I was just trying to figure out how to enable this since it currently doesn't do this. It may make it easier for users to get back to the top.
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
06/13/13 09:54 AM (12 years ago)
Ok I'll understand. 2 things: 1. I don't think you should add too many photos in one album. You'd better sperate them in different ones (albums). This because all the photo's are loaded when you hit the "show me the images" button. A big loading time for the user is the result and also bandwidth use. I tested, when creating the plugin, with a max of 100 images and that went ok. But it also depends on the size of the photos 2. Never added something like you are asking so I have no direct answer. If I ever find a solution I'll post it but keep in mind that it's not on my priority list. Best Regards, Danny
 
mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
like
06/13/13 01:59 PM (12 years ago)
1. Got it, I may look at a way to use less images. I'm pulling in a flickr json feed so I'd love to show more, but I understand it may result in a longer loading time. 2. For sure, I understand! Thanks for the help.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
06/14/13 03:50 PM (12 years ago)
Awesome post and solutions. @mleonard how did you manage to get the Flickr feed to show. Mine always came an error.. Is this right out of the box working or did you make some changes to the code to get it working? Thanks!
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
06/14/13 04:28 PM (12 years ago)
Hi mysps, Have a look at this thread and see the last post: http://www.buzztouch.com/forum/thread.php?tid=DFBAD2F0E8F992A06BEA074&currentPage=1 Hope it helps. Best Regards, Danny
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
06/14/13 07:32 PM (12 years ago)
Thanks! I'll try that
 
mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
like
06/15/13 12:53 PM (12 years ago)
Hey @PSMDanny Testing this out in another app now. When you go back to the main Gallery screen where the "Show Me The Images" button is - does the like button stay on the top left for you? It wasn't doing this in my other app, but I had the thumb gallery as the home screen, so I'm wondering if the refresh button was covering it up...not sure. In this app, it's not the home screen and the like button reappears on the top left after I go "Back" from the photos.
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
06/15/13 12:56 PM (12 years ago)
Hi mleonard, The like button doesn't stay on top of the mainscreen at least in my situation. what if you try to create (for testing purposes) a second tab or menu and put the gallery also in there. See if that changes anything. Best Regards, Danny
 
mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
like
06/15/13 03:44 PM (12 years ago)
Hmm I may need to re-check my code. I'm using a tabbed layout and unless the gallery is on the first tab - with the refresh button - the like button reappears on the top left. I'll try to double check everything. Is it working for you on a tabbed layout?
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
06/16/13 06:19 AM (12 years ago)
Hi mleonard, Just tested with thumbviewer on a tab and you're correct. Scringo likebutton stays on mainscreen. I have no solution (yet)! Best Regards, Danny
 
mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
like
06/16/13 08:19 PM (12 years ago)
Gotcha, good to know I'm not crazy! Thanks for checking.
 

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.