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 12-09-2010, 07:29 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 12
draken182 is on a distinguished road
Default Add search bar to Navigation Controller and UITableView

Hello,
i am new to xcode and have searched tutorials, but most just offer how to use their code and make it search, i already have an app and want to implement a search bar in it. I was wondering is someone could point me in the right direction? Here is .m
Code:
#import "RootViewController.h"
#import "AppDelegate.h"
#import "DetailViewController.h"

@implementation RootViewController

#pragma mark -
#pragma mark Synthesizers

@synthesize table;
@synthesize sitesList;
@synthesize imagesList;
@synthesize descArray;
@synthesize bannerImages;
@synthesize childController;

#pragma mark -
#pragma mark View methods

- (void)viewDidLoad {
	
	NSArray *sites = [[NSArray alloc] initWithObjects:
					  @"#1 or NUMBER ONE",
					  @"#2 or NUMBER TWO",
					  @"#3 or NUMBER THREE",
					  @"1 or ONE",
					  @"10-100,10-1,10-200,10-2,10-4 and 20",
					  @"1000H PAPER",
					  @"129 or HEAVY FROST",
					  @"18% GRAY or GREY CARD",
					  @"180 DEGREE RULE",
					  @"2 or TWO",
					  @"214 or FULL TOUGH SPUN",
					  @"215 or HALF TOUGH SPUN",
					  @"216 or FULL WHITE DIFFUSION",
					  @"220 or WHITE FROST",
					  @"229 or QUARTER TOUGH SPUN",
					  @"250 or HALF WHITE DIFFUSION",
					  @"251 or QUARTER WHITE DIFFUSION",
					  @"252 or EIGHTH WHITE DIFFUSION",
					  @"253 or FULL HAMPSHIRE",
					  @"254 or NEW HAMPSHIRE",
					  @"255 or HOLLYWOOD FROST",
					  @"256 or HALF HAMPSHIRE FROST",
					  @"257 or QUARTER HAMPSHIRE FROST",
					  @"258 or EIGHTH HAMPSHIRE FROST",
					  @"3200K or TUNGSTEN",
					  nil];
	self.sitesList = sites;
	
	[sites release];
	
	
	
	NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Descriptions" ofType:@"plist"];
	
	NSArray *desc = [[NSArray alloc] initWithContentsOfFile:filePath];
	
	self.descArray = desc;
	
	[desc release];
	
	
	
	UIImage *texas = [UIImage imageNamed:@"1andtexas.jpg"];
	UIImage *cali = [UIImage imageNamed:@"2andcalifornia.jpg"];
	UIImage *ny = [UIImage imageNamed:@"3andnewyork.jpg"];
	UIImage *tmark = [UIImage imageNamed:@"1Tmark.jpg"];
	UIImage *walkie = [UIImage imageNamed:@"Walkietalkie.jpg"];
	UIImage *onekh = [UIImage imageNamed:@"Tracingpaper.jpg"];
	UIImage *onetwonine = [UIImage imageNamed:@"diffusion.jpg"];
	UIImage *greycard = [UIImage imageNamed:@"Greycard.jpg"];
	UIImage *oneeighty = [UIImage imageNamed:@"Oneeighty.jpg"];
	UIImage *two = [UIImage imageNamed:@"Two.jpg"];
	UIImage *twofourteen = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twofifteen = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twosixteen = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twotwenty = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twotwentynine = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twofifty = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twofiftyone = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twofiftytwo = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twofiftythree = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twofiftyfour = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twofiftyfive = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twofiftysix = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twofiftyseven = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *twofiftyeight = [UIImage imageNamed:@"Diffusion.jpg"];
	UIImage *thirtytwohk = [UIImage imageNamed:@"3200k.jpg"];
	
	NSArray *banners = [[NSArray alloc] initWithObjects:texas,
						cali,
						ny,
						tmark,
						walkie,
						onekh,
						onetwonine,
						greycard,
						oneeighty,
						two,
						twofourteen,
						twofifteen,
						twosixteen,
						twotwenty,
						twotwentynine,
						twofifty,
						twofiftyone,
						twofiftytwo,
						twofiftythree,
						twofiftyfour,
						twofiftyfive,
						twofiftysix,
						twofiftyseven,
						twofiftyeight,
						thirtytwohk,
						nil];
						
	self.bannerImages = banners;
	
	[banners release];
	
	[app release];
	[creat release];
	[free release];
	[net release];
	[rock release];
	[tuts release];
	[work release];
	 */
	
    [super viewDidLoad];	
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	// Support all the orientations except for PortraitUpsideDown
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

#pragma mark -
#pragma mark Table view datasource methods

-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
	return 1;
}

// A-Z
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
	
    NSMutableArray *toBeReturned = [[NSMutableArray alloc]init];
    for(char c = 'A'; c <= 'Z'; c++) [toBeReturned addObject:[NSString stringWithFormat:@"%c",c]];
    return toBeReturned;
}

-(NSInteger) tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section
{
	return [sitesList count];
}

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	static NSString *CellIdentifier = @"CellIdentifier";
	
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
	
	if (cell == nil) {
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
	}
	
	// Set the title for the cell
	cell.textLabel.text = [sitesList objectAtIndex:indexPath.row];
	
	cell.imageView.image = [imagesList objectAtIndex:indexPath.row];
	
	cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
	
	// Return the cell
	return cell;
}


#pragma mark -
#pragma mark Table view delegate methods

-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
	return 50; // Default height for the cell is 44 px;
}

-(NSString *) tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
	return @"Flm Set Decipher";
}

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
	AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
	
	DetailViewController *detailVC = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
	
	detailVC.banner = [bannerImages objectAtIndex:indexPath.row];
	
	detailVC.description = [descArray objectAtIndex:indexPath.row];
	
	detailVC.title = [sitesList objectAtIndex:indexPath.row];
	
	self.childController = detailVC;
	
	[delegate.navigationController pushViewController:childController animated:YES];
	
	[detailVC release];
	
	[tableView deselectRowAtIndexPath:indexPath animated:YES];
}


#pragma mark -
#pragma mark Memory Management

- (void)didReceiveMemoryWarning {
	NSLog(@"Memory warning!");
    [super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
	self.table = nil;
	self.sitesList = nil;
	self.imagesList = nil;
	self.descArray = nil;
	self.bannerImages = nil;
	self.childController = nil;
	[super viewDidUnload];
}

- (void)dealloc {
	[table release];
	[sitesList release];
	[imagesList release];
	[descArray release];
	[bannerImages release];
	[childController release];
    [super dealloc];
}

@end
draken182 is offline   Reply With Quote
Reply

Bookmarks

Tags
navigation controller, search, search bar, uitableview

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: 389
7 members and 382 guests
chemistry, daudrizek, HemiMG, jeroenkeij, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,665
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, daudrizek
Powered by vBadvanced CMPS v3.1.0

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