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 07-15-2011, 07:40 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 44
Karl6669 is on a distinguished road
Cool Add a UIPickerView to a TabBarController, NavigationController, and TableView

OK, so, I have a TabBar based application. One of the tabs has a navigation controller. One of the navigations leads you to a table view. FROM THERE, I want to have a UIPickerView animate up from the bottom covering the tabBar when my user clicks a certain row in the tableview. However, UIPickerView does not respond to "showFromTabBar" like an action sheet, addSubView seems to put it in the wrong spot and not work correctly with the table views scrolling, etc... The closest technique I have found was to create a blank action sheet and then add the picker view as a subview to that. BUT, the action sheet disables my tableview therefore REQUIRING my user to select something from the pickerview. Also, I couldn't seem to get sizing quite right of the actionsheet behind the pickerview. Anybody done this before and have any suggestions?
Code:
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"" destructiveButtonTitle:nil otherButtonTitles:@"", @"", @"", nil];
    UITabBar *tabBar = self.tabBarController.tabBar;
    [action showFromTabBar:tabBar];
    UIPickerView *picker = [[UIPickerView alloc] init];
    picker.delegate = self;
    picker.dataSource = self;
    [action addSubview:picker];
The reason for the 3 empty strings in the "otherButtonTitles" is just to make the action sheet large enough to hold the pickerview, BUT, it's still a little too big. Anyways, it doesn't work properly. And yes, I know I need to release my ivars. THANKS IN ADVANCE.
Karl6669 is offline   Reply With Quote
Old 07-15-2011, 07:47 PM   #2 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default

Change the @"" to @"\n

"
Quote:
Originally Posted by Karl6669 View Post
OK, so, I have a TabBar based application. One of the tabs has a navigation controller. One of the navigations leads you to a table view. FROM THERE, I want to have a UIPickerView animate up from the bottom covering the tabBar when my user clicks a certain row in the tableview. However, UIPickerView does not respond to "showFromTabBar" like an action sheet, addSubView seems to put it in the wrong spot and not work correctly with the table views scrolling, etc... The closest technique I have found was to create a blank action sheet and then add the picker view as a subview to that. BUT, the action sheet disables my tableview therefore REQUIRING my user to select something from the pickerview. Also, I couldn't seem to get sizing quite right of the actionsheet behind the pickerview. Anybody done this before and have any suggestions?
Code:
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"" destructiveButtonTitle:nil otherButtonTitles:@"", @"", @"", nil];
    UITabBar *tabBar = self.tabBarController.tabBar;
    [action showFromTabBar:tabBar];
    UIPickerView *picker = [[UIPickerView alloc] init];
    picker.delegate = self;
    picker.dataSource = self;
    [action addSubview:picker];
The reason for the 3 empty strings in the "otherButtonTitles" is just to make the action sheet large enough to hold the pickerview, BUT, it's still a little too big. Anyways, it doesn't work properly. And yes, I know I need to release my ivars. THANKS IN ADVANCE.
iSDK is offline   Reply With Quote
Old 07-15-2011, 10:29 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 194
mavrik5150 is on a distinguished road
Default

You could also do it like below (this is how I have a pickerview inside an action sheet, as well as having a Tab & Nav Bar)

Code:
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Sorting Option For Client Tab"
													  delegate:self
											 cancelButtonTitle:@"Cancel"
										destructiveButtonTitle:nil
											 otherButtonTitles:@"Choose",nil];
	
	// Add the picker
	UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,175,0,0)];
	
	pickerView.delegate = self;
	pickerView.showsSelectionIndicator = YES;
    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    int selectedrow = [prefs integerForKey:@"keyClientSelectedRow"];
    [pickerView selectRow:selectedrow inComponent:0 animated:YES];
	
	[menu addSubview:pickerView];
	[menu showInView:self.tabBarController.tabBar];
	[menu setBounds:CGRectMake(0,0,320, 610)];
	
	[pickerView release];
	[menu release];
Depending on if you use landscape mode or this is for an ipad you may need to play with the values a little, this specific app/screen is just for an iphone in portrait view so it works fine for what we need.
mavrik5150 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: 401
15 members and 386 guests
blasterbr, buggen, Clouds, EvilElf, HemiMG, jeroenkeij, jimmyon122, LEARN2MAKE, Mah6447, n00b, nyoe, pungs, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,900
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

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