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 09-03-2010, 02:19 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 7
tariq2305 is on a distinguished road
Question Add Picker/ScrollView on UINavigationBar

Please have a look on this application

Yowza!! Mobile Coupons for iPhone, iPod touch, and iPad on the iTunes App Store

I just want to add custom picker sort of controller on UINavigationBar

Please suggest me any sample or ideas

Thanks
tariq2305 is offline   Reply With Quote
Old 09-03-2010, 05:32 AM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 1
janugandhi is on a distinguished road
Default iPhone Developer

Here is your solution
use this code


//
// RootViewController.m
// delete1
//
// Created by apple apple on 03/09/10.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "RootViewController.h"


@implementation RootViewController

@synthesize pickerViewArray,myPickerView;

#pragma mark -
#pragma mark View lifecycle


- (void)viewDidLoad {

pickerViewArray = [[NSMutableArray alloc] init];

[pickerViewArray addObject:@"Red"];
[pickerViewArray addObject:@"Orange"];
[pickerViewArray addObject:@"Yellow"];
[pickerViewArray addObject:@"Green"];
[pickerViewArray addObject:@"Blue"];
[pickerViewArray addObject:@"Indigo"];
[pickerViewArray addObject:@"Violet"];


myPickerView = [[UIPickerView alloc] initWithFrame:CGRectZero];
myPickerView.delegate=self;

//myPickerView.showsSelectionIndicator =YES;
myPickerView.backgroundColor = [UIColor clearColor];
CGAffineTransform rotate = CGAffineTransformMakeRotation(-3.14/2);
rotate = CGAffineTransformScale(rotate, 0.25, 2.0);
[self.myPickerView setTransform:rotate];
[self.view addSubview:myPickerView];



//Setting Frame

CGRect frame1=CGRectMake(0,0,80,-50);
myPickerView.frame=frame1;
//Adding Picker View on navigationbar
self.navigationItem.titleView = myPickerView;

//self.navigationController.view.frame=frame1;
//self.navigationController.view=myPickerView;
//[myTitleView release];

self.navigationController.navigationBar.tintColor = [UIColor orangeColor];


[super viewDidLoad];

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

-(NSInteger)pickerView: (UIPickerView *)thePickerView numberOfRowsInComponent: (NSInteger)component {

return [pickerViewArray count];
}
//PickerViewController.m
- (NSString *)pickerView: (UIPickerView *)thePickerView titleForRowNSInteger)row forComponent: (NSInteger)component {

return [pickerViewArray objectAtIndex:row];
}

// UIPickerViewDelegate

- (UIView *)pickerView: (UIPickerView *)pickerView viewForRowNSInteger)row forComponentNSInteger)component reusingViewUIView *)view{
CGRect rect = CGRectMake(0, 0, 1024, 40);
UILabel *label = [[UILabel alloc]initWithFrame:rect];
CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14/2);
rotate = CGAffineTransformScale(rotate, 0.25, 2.0);
[label setTransform:rotate];
label.text = [pickerViewArray objectAtIndex:row];
label.font = [UIFont systemFontOfSize:22.0];
label.textAlignment = UITextAlignmentCenter;
label.numberOfLines = 2;
label.lineBreakMode = UILineBreakModeWordWrap;
label.backgroundColor = [UIColor clearColor];
label.clipsToBounds = YES;
return label ;

}


#pragma mark -
#pragma mark Table view data source

// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView: (UITableView *)tableView {
return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView: (UITableView *)tableView numberOfRowsInSection: (NSInteger)section {
return 0;
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Configure the cell.

return cell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView: (UITableView *)tableView canEditRowAtIndexPath: (NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/


/*
// Override to support editing the table view.
- (void)tableView: (UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath: (NSIndexPath *)indexPath {

if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
*/


/*
// Override to support rearranging the table view.
- (void)tableView: (UITableView *)tableView moveRowAtIndexPath: (NSIndexPath *)fromIndexPath toIndexPath: (NSIndexPath *)toIndexPath {
}
*/


/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView: (UITableView *)tableView canMoveRowAtIndexPath: (NSIndexPath *)indexPath {
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/


#pragma mark -
#pragma mark Table view delegate

- (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath {

/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
*/
}


#pragma mark -
#pragma mark Memory management

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Relinquish ownership any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
// For example: self.myOutlet = nil;
}


- (void)dealloc {
[super dealloc];
}


@end
janugandhi is offline   Reply With Quote
Old 09-03-2010, 05:34 AM   #3 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 7
tariq2305 is on a distinguished road
Thumbs up

thanks man.. you are genius
tariq2305 is offline   Reply With Quote
Old 09-03-2010, 06:52 AM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 48
benblanchard is on a distinguished road
Default

How would I do this in IB?
Basically, I see what you're doing here, and want to implement a small Picker View (of the same size here) into a Custom Cell. Anyone have an idea how to do this?
benblanchard is offline   Reply With Quote
Old 05-13-2011, 12:02 AM   #5 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 2
Rafiq Sheik is on a distinguished road
Default scroll view on navigation

Tariq I too have same problem Can u send me the sample.
Rafiq Sheik is offline   Reply With Quote
Old 05-13-2011, 02:22 AM   #6 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Quote:
Originally Posted by Rafiq Sheik View Post
Tariq I too have same problem Can u send me the sample.
i don't understand, what you are trying to achieve exactly?
__________________
dany_dev is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, objectivec, uipickerview, uiscrollview

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: 339
11 members and 328 guests
bignoggins, carlandrews, flamingliquid, ilmman, iram91419, linkmx, nadav@webtview.com, Objective Zero, Paul Slocum, stanny, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,656
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, iram91419
Powered by vBadvanced CMPS v3.1.0

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