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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 01-09-2010, 11:31 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2010
Location: Baton Rouge, LA
Posts: 131
Default how to set UITableViewStyleGrouped in self

Hi all, Im still a newbie at this so I hope my question make sense.

I have a class that is a UITableViewController.
The app has a TabBar, and the item has a navigation controller, which has a view that is of my "OptionsRootController"
So There is no code that loads the "optionsRootContoller", because if there was I would just initWithStyle:UITableViewStyleGrouped, and be done.

So My Questions is how to I from within my OptionsRootController tell it to create the tableView with sections?

I assume that I have to do this in the ViewWillAppear but everything I tried didnt work so I'm asking if anyone knows how to initWithStyle when the class is being loaded from Interface builder....

honestly I'm thinking of going and dumping the Nibs and IB, i have spent more time debugging IB links than actual code..

any helpis greatly appreciated.
j3rm is offline   Reply With Quote
Old 01-09-2010, 12:26 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2010
Location: Baton Rouge, LA
Posts: 131
Default

just to clarify, OptionsRootController is my tableViewClass.
j3rm is offline   Reply With Quote
Old 01-10-2010, 01:12 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2010
Location: Baton Rouge, LA
Posts: 131
Default

Anyone know how this can be done?
Jeremy
j3rm is offline   Reply With Quote
Old 01-10-2010, 01:29 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,129
Default

Code:
- (id)initWithStyle:(UITableViewStyle)style
{
   if (self = [super initWithStyle:UITableViewStyleGrouped])
   {
   }
   return self;
}
__________________
BriTer Ideas LLC - Code review, consulting, development. PM for pricing.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
BrianSlick is offline   Reply With Quote
Old 01-18-2010, 12:44 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2010
Location: Baton Rouge, LA
Posts: 131
Default initWithStyle:UITableViewStyleGrouped from a NIB

Thanks for the code but I tried it and I don't think my first question was accurate..
So take a look at this Nib structure



So the OptionsRootContoller, is the UITableView that I want to always initWithStyle:UITableViewStyleGrouped
But I dont think when its being loaded via the Main nib which has the tab bar, that its calling initWithStyle. I placed logging in this method and nothing is loged.

How do you force a UITableView to be StyleGrouped when its loaded from a Nib?

Thanks for your help
j3rm is offline   Reply With Quote
Old 01-18-2010, 12:48 PM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,129
Default

If OptionsRootController is a table view controller, then crack it open right there, find the table view inside, and change the setting.

If it is a regular view controller, then go to the corresponding XIB for that view controller, and change the table setting there.
__________________
BriTer Ideas LLC - Code review, consulting, development. PM for pricing.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
BrianSlick is offline   Reply With Quote
Old 01-18-2010, 03:00 PM   #7 (permalink)
Registered Member
 
Join Date: Jan 2010
Location: Baton Rouge, LA
Posts: 131
Default

the code you posted is already there. in the .m
There is no NIB files for this controller.
Any other ideas why its not loading grouped?
j3rm is offline   Reply With Quote
Old 01-18-2010, 03:44 PM   #8 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,129
Default

Please post OptionsRootController.h

Also, click the triangle next to OptionsRootController in the previous screen shot, and post a new screen shot.
__________________
BriTer Ideas LLC - Code review, consulting, development. PM for pricing.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:

Last edited by BrianSlick; 01-18-2010 at 03:53 PM.
BrianSlick is offline   Reply With Quote
Old 01-20-2010, 02:37 PM   #9 (permalink)
Registered Member
 
Join Date: Jan 2010
Location: Baton Rouge, LA
Posts: 131
Default

Well I have posted this message 3 times, I'm thinking that the moderators need to approve because I attached the jpg.

So here we go again.
Here is the requested screen shot.




and here is the code from the OptionsViewController.h
Code:
#import <UIKit/UIKit.h>
#define kDefaultLabelTag 50002

@class TextFieldEditingViewController;
@class AppointmentTypesViewController;
@class HistoryTypesViewController;
@class ContactName;


//  Constants representing the Buttons
//
enum {
	
	MActivityTypes,
	MHistoryTypes,
	ContactFields,
	Defaults,
	
	MyAppAccount,
	
	FAQs,
	AboutMyApp
};

//  Constants representing the various sections of our grouped table view.
//
enum {
	Section1,
	Section2,
	Section3
};

typedef NSUInteger ContactAttribute;

@interface OptionsRootController : UITableViewController <UITextFieldDelegate>
{
	AppointmentTypesViewController *_appointmentTypesVC;
	HistoryTypesViewController *_historyTypesVC;
	UINavigationController *_navController; 
	NSManagedObjectContext *managedObjectContext;
}

@property (nonatomic, retain) UINavigationController *navController;
@property (nonatomic, retain) AppointmentTypesViewController *appointmentTypesVC;
@property (nonatomic, retain) HistoryTypesViewController *historyTypesVC;
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;

- (UINavigationController *)navController;
@end
j3rm is offline   Reply With Quote
Old 01-20-2010, 06:38 PM   #10 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,129
Default

Ok, I'm creating a new XIB file.

I'm dragging in a Tab Bar Controller.

I'm dragging a Table View Controller directly to the tab bar.

I crack open that table view controller, and inside I find a table view, which I then change to whatever style I want.



As an alternative, I'm selecting one of the plain view controllers that is already there.

I'm changing its class to a table view controller.

I'm dragging a table view into the list at the same position as shown above.

The table view automatically becomes linked to the view outlet of the view controller.

__________________
BriTer Ideas LLC - Code review, consulting, development. PM for pricing.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
BrianSlick is offline   Reply With Quote
Old 01-21-2010, 10:10 PM   #11 (permalink)
Registered Member
 
Join Date: Jan 2010
Location: Baton Rouge, LA
Posts: 131
Default

I really hate haveing to ask again but I think the problem is that there is a navigation bar in the mix.
here is my nib after doing your suggestion and it appears to be exactly as you reccomended but still no go.



Every looks as it should on left but at run time, its still not grouped.
j3rm is offline   Reply With Quote
Old 01-21-2010, 10:22 PM   #12 (permalink)
Registered Member
 
Join Date: Jan 2010
Location: Baton Rouge, LA
Posts: 131
Default

Nevermind, i hate nib files....

The problem is My NavController/optionsViewController wasnt linked to the optionsViewController for the datasource and the deleteage, once it did that, it was exactly what I wanted.
Thanks for your help.

Last edited by j3rm; 01-21-2010 at 10:26 PM.
j3rm is offline   Reply With Quote
Old 01-21-2010, 10:24 PM   #13 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,129
Default

Don't use table view controllers, problem solved.

You said the code posted above didn't work.
__________________
BriTer Ideas LLC - Code review, consulting, development. PM for pricing.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
BrianSlick is offline   Reply With Quote
Old 04-18-2010, 05:08 PM   #14 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 22
Default

Quote:
Originally Posted by BrianSlick View Post
Code:
- (id)initWithStyle:(UITableViewStyle)style
{
   if (self = [super initWithStyle:UITableViewStyleGrouped])
   {
   }
   return self;
}
I'm having the same issue. The opening UITableViewController in my UINavigationController app is "RootViewController" and I want it to launch with a grouped table. I'm not using IB; I'm doing everything programmatically. I tried pasting this code into RootViewController.m to override the initWithStyle method but it still launches with a plain table. I put a breakpoint in the method and ran the debugger and it never gets called. Any further thoughts?
dmlowe is offline   Reply With Quote
Old 02-11-2011, 05:22 AM   #15 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 1
Default

Code:
- (void)loadView 
{
	[super loadView];
	[self.tableView initWithFrame:CGRectZero style:UITableViewStyleGrouped];	
}
seedstudio is offline   Reply With Quote
Old 02-11-2011, 07:00 AM   #16 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,129
Default

Quote:
Originally Posted by seedstudio View Post
Code:
- (void)loadView 
{
	[super loadView];
	[self.tableView initWithFrame:CGRectZero style:UITableViewStyleGrouped];	
}
I love it when people bump old threads, especially ones in which the question has been answered, and provide a wrong answer. Bonus points for making a new account in order to do this.

Either,
1. The property is empty, which means the init doesn't do anything, or
2. This re-initializes an object that has already been initialized, which you shouldn't do.
__________________
BriTer Ideas LLC - Code review, consulting, development. PM for pricing.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
BrianSlick is offline   Reply With Quote
Old 03-16-2011, 06:25 AM   #17 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 5
Default

Quote:
Originally Posted by seedstudio View Post
Code:
- (void)loadView 
{
	[super loadView];
	[self.tableView initWithFrame:CGRectZero style:UITableViewStyleGrouped];	
}
Tnx, man. It worked like a charm.
Chrizzz is offline   Reply With Quote
Old 03-16-2011, 09:04 AM   #18 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,129
Default

No it doesn't. It leaks.
__________________
BriTer Ideas LLC - Code review, consulting, development. PM for pricing.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
BrianSlick is offline   Reply With Quote
Reply

Bookmarks

Tags
nib, uitableviewcontroller, uitableviewstylegrouped

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: 259
17 members and 242 guests
ADY, Alsahir, dacapo, Dani77, Desert Diva, djohnson, F_Bryant, Grinarn, HemiMG, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, smethorst, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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