Discussion Forums  >  Self Hosted Control Panels

Replies: 14    Views: 92

TraceCampbellBSNRN
buzztouch Evangelist
Profile
Posts: 233
Reg: Dec 16, 2011
Forney
3,680
07/27/12 06:21 PM (13 years ago)

where does this code go?

where in xcode would i put the following code to make an animated header? and is there a way to place it on a button type menu? -(void) viewDidLoad { imageView.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"myImageFrame1.gif"], [UIImage imageNamed:@"myImageFrame2.gif"], [UIImage imageNamed:@"myImageFrame3.gif"], [UIImage imageNamed:@"myImageFrame4.gif"], nil]; imageView.animationDuration = 2.0; imageView.animationRepeatCount = 0; [imageView startAnimating]; }
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/27/12 06:29 PM (13 years ago)
Are you talking about placing a banner in the Nav bar area? I really want to know the answer to this one as well....BT Evangelist in 3..2..1..
 
TraceCampbellBSNRN
buzztouch Evangelist
Profile
Posts: 233
Reg: Dec 16, 2011
Forney
3,680
like
07/27/12 06:32 PM (13 years ago)
no one knows lol. I think number one there is no way to place an animated banner in the nav bar on a button menue, and number two if anyone does know they aint sayin
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/27/12 07:25 PM (13 years ago)
I disagree 100% Take a look at @GoNorthWest @ Alex@TM @ MGoBlue...these guys will answer and they KNOW!
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
07/27/12 11:04 PM (13 years ago)
Must confess...he asked me this already, and I didn't know! But said I would research and get back to him this weekend. Mark
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/27/12 11:10 PM (13 years ago)
I would like to see this as well...thank you! PS: I DM'd you with a question.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
07/28/12 01:07 AM (13 years ago)
Easy...kinda, depending on your understanding...Some things to consider... a) Every screen uses the same method to setup the navigation bar. The method is in the BT_viewUtilities class (inside the BT_Layout folder in the Xcode project). It's called configureBackgroundAndNavBar() and begins on line 215. b) This method is trigged by each individual view controller (plugin's all have their own view controller) in the viewWillAppear() method. This means every time a "view will appear" the method is re-fired. c) The configureBackgroundAndNavBar() has zero understanding of an image for the title, only text. a, b, c mean that all you need to do is modify this method to alter how the title bar behaves / looks / feels. In this case, we want to add an "image view" as the "title view" of the navigation bar. 1) Open BT_Layout > BT_viewUtilities and find the configureBackgroundAndNavBar() method. Scroll to about line 225. This is where it sets the title text. Comment out this code so the title text doesn't get set. 2) Next, create an image view (Called a UIImageView in iOS) object, set an array of images as it's "animated images" property, set the animation properties, set this image view as the title view of the navigation bar. Like... //just after the code you commented out in step 1... /* instantiate an image view object, called "animatedImageView" Set it's frame size accordingly. This example is x = 0, y = 0, width = 320, height = 44, the standard size of the navigation bar. You'll want to create images the same size as the nav bar so iOS doesn't have to scale //them (saves time)... */ UIImageView *animatedImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; /* instantiate an array object of images and set it as the animatedImages property of the animatedImageView all in one step. Note: The last item in the array must be nil. */ animatedImageView.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"image1.png"], [UIImage imageNamed:@"image2.png"], [UIImage imageNamed:@"image3"], nil]; /* set the animation properties. This example will switch images every 2 seconds, 5 times then stop... */ animatedImageView.animationDuration = 2.0; animatedImageView.animationRepeatCount = 5; [animatedImageView startAnimating]; //set the titleView property to the new image view you created. Release the image view [theViewController.navigationItem setTitleView:animatedImageView]; [animatedImageView release]; 3) Save, compile, run. Easy peasy. Things to consider: iOS hates .gif's, use .png's if you can. This modification will set the title image animation the same on every screen. You may not want this. To get around it, you could easily put something like... if([[theScreenData.jsonVars objectForKey:@"itemId"] isEqualToString:@"id of screen..."]){ //put code here to use animated image... }else{ //use the regular title text code } You could also add a new json property to the config data like "animateHeader":"yes" then check for that.... if([[theScreenData.jsonVars objectForKey:@"animateHeader"] isEqualToString:@"yes"]){ //put code here to use animated image... }else{ //use the regular title text code } All sorts of ways to do it. You could also do lots of this in the plugins.m file to (in the viewDidLoadMethod) and skip the layout method altogether. You're a programmer, anything's possible ;-)
 
coderx
Veteran developer
Profile
Posts: 433
Reg: Oct 29, 2011
Ontario, Canada
8,680
like
07/28/12 05:24 AM (13 years ago)
Your explanation makes it easier to implement, even for a rookie. The way I got mine to work is a lot more complicated. I tried your way, easy peasy. Thanks David!!!
 
lsills81
Apple Fan
Profile
Posts: 469
Reg: Mar 19, 2012
location unknow...
14,090
like
07/28/12 08:20 AM (13 years ago)
Thank you guys!!!!
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
07/28/12 01:06 PM (13 years ago)
This was a prime example where "do some research" = "Ask David!" Won't always be that easy though! Thanks, David!
 
TraceCampbellBSNRN
buzztouch Evangelist
Profile
Posts: 233
Reg: Dec 16, 2011
Forney
3,680
like
07/28/12 04:57 PM (13 years ago)
Thank you again. This is why Buzztouch, Buzztouchmods and the family of users here are the future of app development and evolution.
 
TraceCampbellBSNRN
buzztouch Evangelist
Profile
Posts: 233
Reg: Dec 16, 2011
Forney
3,680
like
07/28/12 05:45 PM (13 years ago)
It worked!!!! Is there a way to make this header clickable once it is loaded to make it actually go somewhere or do something?
 
TraceCampbellBSNRN
buzztouch Evangelist
Profile
Posts: 233
Reg: Dec 16, 2011
Forney
3,680
like
07/28/12 06:15 PM (13 years ago)
what would you put if you wanted it to play indefinitely instead of just 5 times
 
coderx
Veteran developer
Profile
Posts: 433
Reg: Oct 29, 2011
Ontario, Canada
8,680
like
07/28/12 06:34 PM (13 years ago)
imageView.animationRepeatCount = 0; 0= represents endless
 
TraceCampbellBSNRN
buzztouch Evangelist
Profile
Posts: 233
Reg: Dec 16, 2011
Forney
3,680
like
07/28/12 07:34 PM (13 years ago)
Is there a way to make this header clickable once it is loaded to make it actually go somewhere or do something?
 

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.