Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 20, 2010, 02:46 AM   #1
psudheer28
macrumors newbie
 
Join Date: Aug 2009
UIScrollView in UITabBarController

Hi all,

thanks in advance,

i am developing an application by using Tab Bar application, with navigation controller.

In first view controller i am displaying table view, after selecting the cell, it will navigates to another view controller, there i have to use UIScrollView.

in scroll view i have taken the frame width and height is 320 and 650, in this scroll view i have to display webimage below that i have to show description of the image in UITextView in remaining space of the scroll view.

how to add these webimage and textview in scrollview, and how to use the scroll view.

plz suggest me

sudheer,
psudheer28 is offline   0 Reply With Quote
Old Aug 20, 2010, 07:34 PM   #2
ianray
macrumors 6502
 
Join Date: Jun 2010
Location: @
Hi! Make a new subclass of UIViewController, for example "PageViewController", and programmatically add the required views.

I stripped the code down to the smallest possible working example, but you will need to take care of memory leaks etc.

Code:
#import <UIKit/UIKit.h>

@interface PageController : UIViewController {
	UIImageView *imageView;
	UITextView  *textView;
}

@property (nonatomic, retain) UIImageView *imageView;
@property (nonatomic, retain) UITextView  *textView;

@end
Code:
#import "PageController.h"

@implementation PageController

@synthesize imageView;
@synthesize textView;

- (void)loadView {
	
	UIScrollView *contentView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
	[contentView setContentSize:CGSizeMake(320, 650 + 100)];

	CGRect r;
	r.origin.x    = 0;
	r.origin.y    = 0;
	r.size.width  = 320;
	r.size.height = 650;
	imageView = [[UIImageView alloc] initWithFrame:r];
	imageView.image = [UIImage imageNamed:@"apple.jpg"];

	r.origin.y    = 650;
	r.size.height = 100;
	textView = [[UITextView alloc] initWithFrame:r];
	textView.backgroundColor = [UIColor blueColor];
	textView.text = @"Hello, world";
	
	[contentView addSubview:imageView];
	[contentView addSubview:textView];

	self.view = contentView;
	[contentView release];
}

- (void)dealloc {
	[imageView removeFromSuperview];
	[textView  removeFromSuperview];
	self.imageView = nil;
	self.textView  = nil;
        [super dealloc];
}

@end

Hope this helps
__________________
My App Store Apps: Dashometer, Exinf, Score&Grade
ianray is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Resolved: UIScrollView does not scroll a UIImageView Tex-Twil iPhone/iPad Programming 4 Nov 20, 2013 07:57 AM
UITableView in UIScrollview IDMah iPhone/iPad Programming 4 Aug 4, 2013 12:25 PM
Resolved: UITabBarController show only 1 tab igorladessa iPhone/iPad Programming 1 Dec 19, 2012 07:52 AM
[Resolved]. Switching from UITableViewController, to new UITabBarController StigProgram iPhone/iPad Programming 4 Nov 16, 2012 04:58 PM
Resolved: how to access child controllers of a UITabBarController? Tex-Twil iPhone/iPad Programming 7 Jul 30, 2012 10:18 AM

Forum Jump

All times are GMT -5. The time now is 09:32 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC