Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 17    Views: 73

Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
05/13/13 04:18 PM (12 years ago)

Developer Question

I'm in the process of creating an app with a simple UI. It is a tab bar controller with a UIScrollView within. I have the scroller working well, and within the nav bar I have 3 UIButtons, one for Twitter Sheet, one for Facebook sheet and one for email. When I hit the twitter and facebook sheets and you return to the UIScrollView, the scroller still works fine. When I hit the email and either send or delete the draft and return to the view the scroller doesnt scroll. I've read lots about autolayout which I need in place so it looks right on both iPhone 5 and 4. So it would appear the change of view to the email view isnt releasing properly when returning to the UIScrollView. I've tried adding release properties to the code, i've messed about with the appdelegate but I cannot get this fix. Anyone any clue? Thanks!
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
05/13/13 07:35 PM (12 years ago)
Are you using the email plugin's as a template? Check out the code inside there for some ideas.
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
05/14/13 02:10 AM (12 years ago)
Autolayout probably has little to do with the scrolling. Are you setting the content size? i.e. [myScroller setContentSize:CGSizeMake(320, 500)]; -tM
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
05/14/13 02:11 AM (12 years ago)
My plugin didn't scroll anyway, so I'm not sure if it works or not. But I pretty much stole both the email and the sms code from the code David wrote in parts of the BT_viewControllerManager.m file. It just pops up a property sheet that disappears once the user has committed an action, whether to send or to cancel. Maybe it'll help. Hope so, but let us know what you end up doing. Cheers! -- Smug Edit: perhaps a quick refresh after the email method has finished?
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/14/13 02:17 AM (12 years ago)
@monster Yes, declared twice although thats over kill, only needed in viewWillAppear -(void)viewWillAppear:(BOOL)animated{ [scrollView setFrame:CGRectMake(0, 0, 320, 800)]; } -(void)viewDidAppear:(BOOL)animated { [scrollView setScrollEnabled:YES]; [scrollView setContentSize:CGSizeMake(320, 800)]; } @smug - Thats what it is doing, bringing up a 'sheet' email then releasing back to the original view. Weirdly, if I then press the 2nd tab and return to the first tab it scrolls again. Something is not releasing. I couldnt find a .h and .m in the email plugin, i'll check your suggestion in the BT_viewControllerManager Cheers
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/14/13 02:17 AM (12 years ago)
This is an app outside of the BT framework..
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
05/14/13 02:21 AM (12 years ago)
Ah... There's your problem...The way ScrollViews work is with a "Content View" and a Frame. Think of the Frame like the Frame of a Window looking outside. Since the outside is obviously a lot bigger than the size of that Window, you can move the Window to see more of the outside. So think of the outside like the ContentView. And Think of the Frame as a Window. So what you want is something like: //[scrollView setFrame:CGRectMake(0,0,320,self.view.frame.size.height)]; // if you have autoLayout you really don't need this line. [scrollView setContentSize:CGSizeMake(320,800)];
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/14/13 02:30 AM (12 years ago)
Just checked, same code for email as used here. Replaced line as you said to [scrollView setFrame:CGRectMake(0,0,320,self.view.frame.size.height)]; and removed other line then didn't scroll at all! Reinstated [scrollView setContentSize:CGSizeMake(320,800)]; and left [scrollView setFrame:CGRectMake(0,0,320,self.view.frame.size.height)]; in and same issue. Might be a bug although if I used email on a BT app in a table scroll view and return it still scrolls fine. Maybe UIScrollView is different. Perhaps a bug?
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
05/14/13 02:31 AM (12 years ago)
No, remove [scrollView setFrame:CGRectMake(0,0,320,self.view.frame.size.height)]; (if your using a nib or storyboards) and make sure you have [scrollView setContentSize:CGSizeMake(320,800)]; -tM
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/14/13 02:39 AM (12 years ago)
Thats what I had, you suggested to add [scrollView setFrame:CGRectMake(0,0,320,self.view.frame.size.height)] ?? My original code -(void)viewWillAppear:(BOOL)animated{ [scrollView setFrame:CGRectMake(0, 0, 320, 800)]; } -(void)viewDidAppear:(BOOL)animated { [scrollView setScrollEnabled:YES]; [scrollView setContentSize:CGSizeMake(320, 800)]; }
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
05/14/13 02:46 AM (12 years ago)
Haha sorry I think I confused ya... This is what your code should look like: - (void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // if you are NOT using a nib or storyboard, then uncomment the next line // [scrollView setFrame:CGRectMake(0,0,320,self.view.frame.size.height)]; [scrollView setScrollEnabled:YES]; [scrollView setContentSize:CGSizeMake(320, 800)]; } -tM
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/14/13 03:02 AM (12 years ago)
I am using a nib, So just add [super viewDidAppear:animated]; ?
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/14/13 03:05 AM (12 years ago)
No improvement :/
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
05/14/13 11:17 AM (12 years ago)
Hmm... Something else is going on then, is your scrollView in the nib 320x430 ish? Also would you mind posting more code? -tM
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/14/13 11:32 AM (12 years ago)
320x584 at the moment but I will probably need to make it bigger. If it goes above 800 I know the code must be higher for it to scroll. Really strange. If I import another view controller and change views completely, when I push back to the view, same issue, wont scroll. Must be a bug?
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
05/14/13 11:34 AM (12 years ago)
The frame must be smaller than the content size that you set it to for it to scroll. Not sure if it's a bug, could be from what your saying. -tM
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/14/13 11:39 AM (12 years ago)
Yeah, thats the correct way of saying what I meant!! So annoying, not that its imperative I resolve, I can put the function elsewhere, more I do not like being beaten! Thanks for taking a look.
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
05/14/13 11:51 AM (12 years ago)
Well if you want more help let me know. And it sounds like it has to do with something else other than the frame and content size. -tM
 

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.