Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-07-2012, 04:08 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2012
Posts: 1
alapimba is on a distinguished road
Default hot to make uiscrollview inside uitabbarcontroller?

Hello

I have a view that i'd like to put inside a uiscrollview and the uiscrollview in a uitabcontroller but i'm missing something.
Can anyone help me here please? i have searched the documentation buti can't figure how to do this programaticly. using a xib i have no problems..

my code:
appdelegate.h
Code:
#import <UIKit/UIKit.h>
#import "area1.h"
#import "area2.h"


@interface subviewsAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) IBOutlet UIWindow *window;

@end
appdelegate.m:
Code:
@implementation subviewsAppDelegate

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    [[self window] setRootViewController:tabBarController];
    
    NSMutableArray *x = [NSMutableArray array];
    
    [x addObject: [[[area1 alloc] init] autorelease]];
    [x addObject: [[[area2 alloc] init] autorelease]];
    
    [tabBarController setViewControllers:x];
    
    [tabBarController release];
    
    [[self window] makeKeyAndVisible];
    return YES;
}
area2.h
Code:
#import <UIKit/UIKit.h>
#import "imageScrollProgramaticamente.h"

@interface area2 : UIViewController
{
    UIScrollView* scrollView;
}

@property (nonatomic, retain) IBOutlet UIScrollView* scrollView;


@end
area2.m
Code:
#import "area2.h"

@implementation area2

@synthesize scrollView;

- (id)init
{
    if(self = [super init]) 
    {
        UITabBarItem *tbi = [self tabBarItem];
        [tbi setTitle:@"area2"];
        
        
        
    }
    
    return self;
}

- (void)viewDidLoad
{
 [super viewDidLoad];
    imageScrollProgramaticamente *isp = [[imageScrollProgramaticamente alloc] initWithFrame:CGRectZero];
    [self setView:isp];
    [isp setBackgroundColor:[UIColor orangeColor]];
    [isp release]; 
   
    

}
imagescrollprogramaticamente.h

Code:
#import <UIKit/UIKit.h>

@interface imageScrollProgramaticamente : UIScrollView{
    
}
imageprogramaticamente.m
Code:
#import "imageScrollProgramaticamente.h"

@implementation imageScrollProgramaticamente

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
    }
    return self;
}

- (void)drawRect:(CGRect)rect
{
    //what rectangle am i filling?
    CGRect bounds = [self bounds];
    
    //where is the center?
    CGPoint center;
    center.x = bounds.origin.x + bounds.size.width / 2.0;
    center.y = bounds.origin.y + bounds.size.height /2.0;
    
    //from the center how far out of a corner?
    //float maxRadius = hypotf(bounds.size.width, bounds.size.height) /2.0;
    
       
    //create a string
    NSString *text = @"apple";
    
    //get a font to draw it in
    UIFont * font = [UIFont boldSystemFontOfSize:200];
    
    //where am i going to draw it?
    CGRect textRect;
    textRect.size = [text sizeWithFont:font];
    textRect.origin.x = center.x - textRect.size.width / 2.0;
    textRect.origin.y = center.y - textRect.size.height / 2.0;
    
    //set the fill color of the current context to black
    [[UIColor blackColor] setFill];
    
    
    
    //draw the string
    [text drawInRect:textRect withFont:font];
}




@end
now... how can i make this imagescrollprogramaticamente...scroll?

Regards
alapimba is offline   Reply With Quote
Old 02-07-2012, 09:59 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 17
mathieuh is on a distinguished road
Default

To put your view inside a superView, use

Code:
[view addSubView:subView];
where view is the scrollView and subView is the view you want to add to it.
mathieuh is offline   Reply With Quote
Old 02-07-2012, 11:21 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 280
dapis is on a distinguished road
Default

Maybe I'm misunderstanding your question, but I have scrollviews in several views (only one per relevant view) in tabbar apps, and all I did in each case was simply add the scrollview in Interface Builder and provide links to them as IBOutlets and of course set the delegate of the scrollview to its File's Owner and set the delegate properly in the source code as well.
dapis is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 413
17 members and 396 guests
Alex-alex, Apptronics RBC, baja_yu, dre, FrankWeller, gwelmarten, ipodphone, jeroenkeij, jleannex55, matador1978, n00b, pbart, reficul, Retouchable, Sami Gh, usernametaken, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:18 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0