How to subclass TTPhotoViewController to add a button

105 views
Skip to first unread message

Rémy Virin

unread,
Dec 22, 2010, 6:16:46 PM12/22/10
to Three20
Hi,

I'd like to subclass TTPhotoViewController, because I need to add a
button (like the one in facebook to see the comments and the likes)

I didn't found a solution, How can I do that ?

Thanks a lot :)

Rémy.

Trausti Thor Johannsson

unread,
Dec 22, 2010, 9:16:20 PM12/22/10
to thr...@googlegroups.com
I don't have the full information infront of me, but the
TTPhotoViewController contains a lot of views, find the correct view
and add a button to it, custom button.

It is real simple.

Right click the text TTPhotoViewController, pick jump to definition,
pick the .h file, and you see all views.

Trausti

> --
> You received this message because you are subscribed to the Google
> Groups "Three20" group.
> To post to this group, send email to thr...@googlegroups.com
> To unsubscribe from this group, send email to
> three20+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/three20?hl=en
>
> To learn more about Three20, check out
> http://Three20.info/
>

Rémy Virin

unread,
Dec 23, 2010, 4:26:26 AM12/23/10
to Three20
I'm not sure to understand everything.

Correct me if I'm wrong.

TTPhotoViewController contains a UIToolBar, which contains 2
UIbarButtonItems : _nextButton and _previousButton.

I tried to modify the UIToolBar but I can't, because it's a private
variable.

So the only way I found, is to modify TTPhotoViewController, which is
quite a bad idea I think...

Am I correct ?

Thanks for your help Trausti.

Rémy.

On 23 déc, 03:16, Trausti Thor Johannsson <t...@studlar.net> wrote:
> I don't have the full information infront of me, but the
> TTPhotoViewController contains a lot of views, find the correct view
> and add a button to it, custom button.
>
> It is real simple.
>
> Right click the text TTPhotoViewController, pick jump to definition,
> pick the .h file, and you see all views.
>
> Trausti
>

Alex Corcoran

unread,
Jan 6, 2011, 1:15:43 AM1/6/11
to Three20
Hey I'm trying to do the same thing for a Save button. Did you ever
figure out how to subclass or modify TTPhotoViewController?

Alex Corcoran

unread,
Jan 6, 2011, 3:07:15 AM1/6/11
to Three20
I figured it out. I subclassed TTPhotoViewController as such

PhotoController.h:

#import <Foundation/Foundation.h>
#import <Three20/Three20.h>

@interface PhotoController : TTPhotoViewController
<TTScrollViewDelegate>{
}

@end


PhotoController.m:

#import "PhotoController.h"
#import "TourPhotoSource.h"

@implementation PhotoController
-(void)viewDidLoad{
// New item to be added
UIBarButtonItem *customItem = [[UIBarButtonItem alloc]
initWithTitle:@"Save" style:UIBarButtonItemStyleBordered target:self
action:@selector(action:)];
// Flex space to keep the back / forward arrows centered
UIBarButtonItem *flex = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil action:nil];

// Create array with items starting with the left side
NSMutableArray *items = [NSMutableArray arrayWithObject:flex];
// Then add the current items (the back / forward arrows)
[items addObjectsFromArray:[_toolbar items]];
// Add in our new item to the far right
[items addObject:customItem];

[_toolbar setItems:items];
[customItem release];
[flex release];
}

-(void)action:(id)sender{
// Perform your action
}

@end

For saving a photo it required some other adjustments in my TTPhoto
subclass and such but that should at least help you add the button.
Hope that helps. Good luck!

Nic Hubbard

unread,
Feb 16, 2011, 12:42:07 PM2/16/11
to Three20
How did you then use your subclassed TTPhotoViewController? I am
using the mockphotosource code from TTCatalog, and I am not seeing how
TTPhotoViewController is implemented.

On Jan 6, 1:07 am, Alex Corcoran <alex.p.corco...@gmail.com> wrote:
> I figured it out. I subclassedTTPhotoViewControlleras such
> > >TTPhotoViewControllercontains a UIToolBar, which contains 2
> > > UIbarButtonItems : _nextButton and _previousButton.
>
> > > I tried to modify the UIToolBar but I can't, because it's a private
> > > variable.
>
> > > So the only way I found, is to modifyTTPhotoViewController, which is
> > > quite a bad idea I think...
>
> > > Am I correct ?
>
> > > Thanks for your help Trausti.
>
> > > Rémy.
>
> > > On 23 déc, 03:16, Trausti Thor Johannsson <t...@studlar.net> wrote:
>
> > > > I don't have the full information infront of me, but the
> > > >TTPhotoViewControllercontains a lot of views, find the correct view
> > > > and add a button to it, custom button.
>
> > > > It is real simple.
>
> > > > Right click the textTTPhotoViewController, pick jump to definition,
> > > > pick the .h file, and you see all views.
>
> > > > Trausti
>
> > > > On Thu, Dec 23, 2010 at 12:16 AM, Rémy Virin <virinr...@gmail.com> wrote:
> > > > > Hi,
>
> > > > > I'd like to subclassTTPhotoViewController, because I need to add a

Natan Alves

unread,
Mar 14, 2011, 5:35:36 PM3/14/11
to Three20
Someone managed to solve this issue? I want to do something like this
but could not find an answer.

[]s
> > > Hey I'm trying to do the same thing for a Savebutton. Did you ever
> > > figure out how to subclass or modifyTTPhotoViewController?
>
> > > On Dec 23 2010, 3:26 am, Rémy Virin <virinr...@gmail.com> wrote:
>
> > > > I'm not sure to understand everything.
>
> > > > Correct me if I'm wrong.
>
> > > >TTPhotoViewControllercontains a UIToolBar, which contains 2
> > > > UIbarButtonItems : _nextButton and _previousButton.
>
> > > > I tried to modify the UIToolBar but I can't, because it's a private
> > > > variable.
>
> > > > So the only way I found, is to modifyTTPhotoViewController, which is
> > > > quite a bad idea I think...
>
> > > > Am I correct ?
>
> > > > Thanks for your help Trausti.
>
> > > > Rémy.
>
> > > > On 23 déc, 03:16, Trausti Thor Johannsson <t...@studlar.net> wrote:
>
> > > > > I don't have the full information infront of me, but the
> > > > >TTPhotoViewControllercontains a lot of views, find the correct view
> > > > > and add abuttonto it, custombutton.
>
> > > > > It is real simple.
>
> > > > > Right click the textTTPhotoViewController, pick jump to definition,
> > > > > pick the .h file, and you see all views.
>
> > > > > Trausti
>
> > > > > On Thu, Dec 23, 2010 at 12:16 AM, Rémy Virin <virinr...@gmail.com> wrote:
> > > > > > Hi,
>
> > > > > > I'd like to subclassTTPhotoViewController, because I need to add a
> > > > > >button(like the one in facebook to see the comments and the likes)

Phillip Verheyden

unread,
Apr 5, 2011, 1:38:49 PM4/5/11
to thr...@googlegroups.com
Sorry, just stumbled across someone else's post for this:

http://sol3.typepad.com/tagalong_developer_journa/2009/12/adding-savetoalbum-to-the-ttphotoviewcontroller.html

Thanks,
Phillip

--
We are moving away from Google Groups as our primary community in favor of a new, custom-made Vanilla forums setup. Please start asking questions there going forward. We will continue supporting the Three20 Google Group at least until April 9th of 2011.

http://forums.three20.info/
Reply all
Reply to author
Forward
0 new messages