Help debugging UITableView, shows no data - iphone

I was first tasked to create a popover that came from a BarButtonItem, and then based on selection in that popover (which was a tableview), another popover would present itself from the cell with the data. The data I had was correctly presented that way. In the debugger, I still see the data in my cellForRowAtIndexPath with NSLog what's in the self.CategoriesArray. For some reason though, the data will not show... Now however, they don't want the initial popover, and just one popover that comes from the BarButtonItem. For the life of me, I cannot figure out why my data is not being presented since all that change should be is replacing the first UITableView in the popover, with the second UITableView. Unless I'm missing something..... Any help would be appreciated. Thanks!
cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == _filterTableView || tableView == _categoriesTableView) {
static NSString *simpleIdentifier = #"SimpleIdentifier";
UITableViewCell *simpleCell = [tableView dequeueReusableCellWithIdentifier:simpleIdentifier];
if (simpleCell == nil) {
simpleCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleIdentifier];
}
NSUInteger row;
row = [indexPath row];
simpleCell.textLabel.textColor = [UIColor whiteColor];
simpleCell.selectionStyle = UITableViewCellSelectionStyleNone;
// first popover
if (tableView == _filterTableView) {
simpleCell.textLabel.text = [_filterArray objectAtIndex:row];
return simpleCell;
}
// second popover
else if (tableView == _categoriesTableView) {
simpleCell.textLabel.text = [_categoriesArray objectAtIndex:row];
return simpleCell;
}
- (IBAction)FilterButtonPressed:(id)sender {
// This part works for two popovers
// UIViewController *contentViewController = [[UIViewController alloc] init];
// self.FilterTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 200, 150) style:UITableViewStylePlain];
// self.FilterTableView.delegate = self;
// self.FilterTableView.dataSource = self;
// self.FilterTableView.bounces = NO;
// self.FilterTableView.scrollEnabled = NO;
// self.FilterTableView.backgroundColor = [UIColor clearColor];
// contentViewController.contentSizeForViewInPopover = CGSizeMake(200, 150);
// contentViewController.view = _filterTableView;
//
// self.FilterPopoverController = [[UIPopoverController alloc] initWithContentViewController:contentViewController];
// [self.FilterPopoverController presentPopoverFromBarButtonItem:_filterButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
//
// [contentViewController release];
// New code tfor one popover
[self loadCategories];
UIViewController *contentViewController = [[UIViewController alloc] init];
self.CategoriesTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) style:UITableViewStylePlain];
self.CategoriesTableView.delegate = self;
self.CategoriesTableView.dataSource = self;
self.CategoriesTableView.bounces = NO;
self.CategoriesTableView.scrollEnabled = YES;
self.CategoriesTableView.backgroundColor = [UIColor clearColor];
contentViewController.contentSizeForViewInPopover = CGSizeMake(320, 500);
contentViewController.view = _categoriesTableView;
self.FilterPopoverController = [[UIPopoverController alloc] initWithContentViewController:contentViewController];
self.FilterPopoverController.delegate = self;
[self.FilterPopoverController presentPopoverFromBarButtonItem:_filterButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[contentViewController release];
}
}

I recognize this code from your other question. :) You're setting your text color to white, and the default background color of the cell is also white. Is this the same bug? Try setting a different background color for your cell.
If that doesn't fix it, there's one other thing you could check. You're setting this:
contentViewController.view = _categoriesTableView;
but it's not clear from your code where _categoriesTableView comes from. Do you have #synthesize CategoriesTableView = _categoriesTableView; at the top of your implementation?
Set a breakpoint on that view assignment and make sure _categoriesTableView isn't nil.

Related

UISegmentedControl not updating view

I am building an app in Xcode 5, and I ran into some strange behavior of UISegmentedControl.
first some info on the app i'm building:
I'm building an app in which I want to allow users to order products at registered companies. As an extra service, I want to allow them to see the orders they did, and even to filter the orders on their status: All orders, Active orders & Delivered orders. the orders are displayed in a UITableView, and I created a UISegmentedControl inside the header view to filter the orders. when the selectedSegmentIndex of that UISegmentedControl changes, it executes an NSPredicate to filter the array and display only the desired orders.
now it's working all fine, except for 1 thing: The UISegmentedControl I have does not update it's view when I select another segment. It's default selectedSegmentIndex is 'Active', because users are probably most interested in the active orders, but when I change it to 'All', the tableview displays all orders (so the predicate is working), but the view remains on the same selectedSegmentIndex.
I did a lot of research to solve this but no answer solves my problem.. my code:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if(section == 0) {
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f,0.0f, 320, 45)]; // x,y,width,height
//label
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320, 20)];
title.text = #"Kies een filter...";
[headerView addSubview:title];
//segmentedcontrol
NSArray *itemArray = [NSArray arrayWithObjects: #"Alle", #"Actief", #"Afgehandeld", nil];
control = [[UISegmentedControl alloc] initWithItems:itemArray];
[control setFrame:CGRectMake(0.0f, 20.0f, 320.0, 35.0)];
control.userInteractionEnabled = YES;
control.tintColor = [UIColor blackColor];
[control setEnabled:YES];
[control addTarget:self action:#selector(changeFilter:) forControlEvents:UIControlEventAllEvents];
[headerView addSubview:control];
//label containing selected filter info
UILabel *info = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 55.0f, 320, 20)];
if ([selectedFilterInfo isEqualToString:#"Alle"]) {
info.text = #"Alle orders:";
}
else if ([selectedFilterInfo isEqualToString:#"Actief"]) {
info.text = #"Alle actieve orders:";
}
else if ([selectedFilterInfo isEqualToString:#"Afgehandeld"]) {
info.text = #"Alle afgehandelde orders:";
}
[headerView addSubview:info];
headerView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"bar.png"]];
return headerView;
}
}
and the action it triggers:
- (void)changeFilter:(id)sender {
UISegmentedControl *segmentedControl = (UISegmentedControl *)sender;
if (segmentedControl.selectedSegmentIndex == 0) {
selectedFilterInfo = #"Alle";
filteredArray = nil;
[segmentedControl reloadInputViews];
[segmentedControl setSelectedSegmentIndex:0];
}
else if (segmentedControl.selectedSegmentIndex == 1) {
NSPredicate *deliveredpredicate = [NSPredicate predicateWithFormat:#"SELF.delivered contains[c] %#", #"0"];
NSMutableArray *notDeliveredArray = [NSMutableArray arrayWithArray:[sortedArray filteredArrayUsingPredicate:deliveredpredicate]];
filteredArray = [NSMutableArray arrayWithArray:notDeliveredArray];
selectedFilterInfo = #"Actief";
[segmentedControl reloadInputViews];
[segmentedControl setSelectedSegmentIndex:1];
}
else if (segmentedControl.selectedSegmentIndex == 2) {
NSPredicate *deliveredpredicate = [NSPredicate predicateWithFormat:#"SELF.delivered contains[c] %#", #"1"];
NSArray *deliveredArray = [sortedArray filteredArrayUsingPredicate:deliveredpredicate];
filteredArray = [NSMutableArray arrayWithArray:deliveredArray];
selectedFilterInfo = #"Afgehandeld";
[segmentedControl reloadInputViews];
[segmentedControl setSelectedSegmentIndex:2];
}
[self.tableView reloadData];
}
I did not include the numberOfCellsInSection etcetera because the tableview part is working perfectly. the only thing that's not working is updating the view.
Any solution would be really appreciated, Thank you all in advance!!
reloadData will reload the tableView, and when you reload the tableView all headerViews will be reloaded too. When the tableView was reloaded there is a new header. And the UISegmentedControl you see now is not the one that you have tapped.
Create an ivar that holds your selected index
#implementation .. {
NSInteger selectedIndex;
}
when creating the view restore the saved index
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
/* ... */
control = [[UISegmentedControl alloc] initWithItems:itemArray];
control.selectedSegmentIndex = selectedIndex;
/* ... */
}
save the index when changing the segmentedControl
- (void)changeFilter:(id)sender {
UISegmentedControl *segmentedControl = (UISegmentedControl *)sender;
selectedIndex = segmentedControl.selectedSegmentIndex;
if (segmentedControl.selectedSegmentIndex == 0) {
selectedFilterInfo = #"Alle";
filteredArray = nil;
}
/* ... */
// reloads the table and all header views!
[tableView reloadData];
}
And btw. when you use UISegmentedControls there is no need to call setSelectedSegmentIndex: on it again, the tap sets the index already. And reloadInputViews is totally useless for a UISegmentedControl. But I guess this code was just added because it didn't work. Don't forget to remove it ;-)

Hide UIPickerview On Done Button in UITableView

I have UITextField in each Cell of UITableview and I have added UIPickerview as inputView of UITextField and showing with Done button at its tool bar
My question is how can I hide this this pop up (Picker + toolbar) on click of done button ?
and show selected value of picker in text box in particular cell ?
Thanks and Regards
Edit : Code
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
PremiumProductsDescriptionCell *cell = (PremiumProductsDescriptionCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[PremiumProductsDescriptionCell alloc] initShoppingCartCellWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
ShopProduct *p = (ShopProduct *)[[ShopProduct GetShoppingCart] objectAtIndex:indexPath.row];
cell.Quantity.text = [NSString stringWithFormat:#"%d",p.Quantity];
UIPickerView *quantityPicker = [[UIPickerView alloc] init];
quantityPicker.dataSource = self;
quantityPicker.delegate = self;
UIToolbar *myToolbar = [[UIToolbar alloc] initWithFrame:
CGRectMake(0,0, 320, 44)];
UIBarButtonItem *doneButton =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self action:#selector(hideKeyBoard)];
quantityPicker.tag = indexPath.row;
[myToolbar setItems:[NSArray arrayWithObject: doneButton] animated:NO];
cell.Quantity.inputAccessoryView = myToolbar;
cell.Quantity.inputView = quantityPicker;
cell.Quantity.delegate = self;
return cell;
}
Solved :
I have taken currentTextBox a variable and added following method and resizing its first responder in done button's click :)
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
currentTextBox = textField;
}
UIPopOver cant be dismissed from their class and you need to dismiss it from the calling class.
You have to call dismiss method from popover calling class, when user presses the done button
-(void)doneButtonClikd
{ ParentClass *viewController=[ParentClass alloc]init];
[viewController dismissPopOver];
}
I think this will solve your problem
For your inputview-
-(void)doneButtonclikd
{ [selectedTextfield resignFirstResponder];
}
Dont forget to save the currently selected textfield.
Assuming you put the UIPickerView in a popover, here's how to do it:
UIPopoverController* popover = ....
UIBarButtonItem* doneButton = ....
[doneButton addTarget:self action:#selector(closeMe)
forControlEvents:UIControlEventTouchUpInside]
// ....
- (void)closeMe
{
// Assuming popover is really a field or something...
[popover dismissPopoverAnimated:YES];
}
Use [self.view endEditing:YES] method.

How to reload current UIView

I have a method I am calling from my mainview that is setting the image name of the image I want to display in a scrollview.
- (void)loadImage:(NSString *)myImageName
{
if (myImageName == #"one") {
imageName = myImageName;
}
if (myImageName == #"two") {
imageName = myImageName;
}
if (myImageName == #"three") {
imageName = myImageName;
}
//Reloads view here???
}
I am loading the images in my viewdidload method like so
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//Create scrollview
scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
scrollView.delegate = self;
scrollView.bounces = NO;
//Create scrollviewimage
if (imageName == #"one") {
image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"ha.png"]];
}
if (imageName == #"two") {
image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"haha.png"]];
}
if (imageName == #"three") {
image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"hahaha.png"]];
}
containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 550)];
//Add subview
[containerView addSubview:image];
//initViews
scrollView.contentSize = containerView.frame.size;
[scrollView addSubview:containerView];
//scrolling
scrollView.minimumZoomScale = 1.0;
scrollView.maximumZoomScale = 31.0;
[scrollView setZoomScale:scrollView.minimumZoomScale];
//highrachy
[self.view addSubview:scrollView];
}
What happens when I set the imagename from the parentview from a tableviewcell selection I pass down the nsstring into loadImage.. then load image sets the name in viewdidload.. however what is happening is that only the first selection dose anything.. so you will always see the first image you are selecting.. so if you pick image two every other image you select will show image two..
any help would be great.
here is what the parentview cell selection looks like
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Sets the back button for the new view that loads (this overrides the usual parentview name with "Back")
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Back" style: UIBarButtonItemStyleBordered target:nil action:nil];
if (!self.detailViewController) {
self.detailViewController = [[ICDDetailViewController alloc] initWithNibName:#"ICDDetailViewController" bundle:nil];
if (indexPath.section == 0) {
_detailViewController.imageName = #"one";
// NSLog(#"%#", indexPath);
}
if (indexPath.section == 1) {
_detailViewController.imageName = #"two";
// NSLog(#"%#", indexPath);
}
if (indexPath.section == 2) {
_detailViewController.imageName = #"three";
// NSLog(#"%#", indexPath);
}
}
[self.navigationController pushViewController:self.detailViewController animated:YES];
}
Don't use myImageName == #"three". There's a special method for comparing strings.
try this:
if ([myImageName isEqualToString:#"three"]) {
[image setImage:[UIImage imageNamed:myImageName]];
}
If there is a file extension, do this:
NSString *imagePath = [NSString stringWithFormat:#"%#.png",myImageName];
[image setImage:[UIImage imageNamed:imagePath]];
By the way, you are still posting the old code you had in your other question. You are retaining your detailView in your original class instead of releasing and creating a new instance. Take out the if (!detailView) statements.
Update: the only other option is to take the assignments out of the large if( ) block.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Sets the back button for the new view that loads (this overrides the usual parentview name with "Back")
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Back" style: UIBarButtonItemStyleBordered target:nil action:nil];
if (!self.detailViewController) {
self.detailViewController = [[ICDDetailViewController alloc] initWithNibName:#"ICDDetailViewController" bundle:nil];
//MY CHANGES HERE:
//If you left these if () statements inside the original code, they would never
//fire if the detailView was already instantiated once. Does this make sense?
} // <--- moved the bracket up here
if (indexPath.section == 0) {
_detailViewController.imageName = #"one";
// NSLog(#"%#", indexPath);
}
if (indexPath.section == 1) {
_detailViewController.imageName = #"two";
// NSLog(#"%#", indexPath);
}
if (indexPath.section == 2) {
_detailViewController.imageName = #"three";
// NSLog(#"%#", indexPath);
}
//} <--- commented this one out
[self.navigationController pushViewController:self.detailViewController animated:YES];
}
The only other way is this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Sets the back button for the new view that loads (this overrides the usual parentview name with "Back")
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Back" style: UIBarButtonItemStyleBordered target:nil action:nil];
//commented out the next line, don't need to check to see if it's already present
//just create a new instance to push on the stack
//if (!self.detailViewController) {
self.detailViewController = [[ICDDetailViewController alloc] initWithNibName:#"ICDDetailViewController" bundle:nil];
if (indexPath.section == 0) {
_detailViewController.imageName = #"one";
// NSLog(#"%#", indexPath);
}
if (indexPath.section == 1) {
_detailViewController.imageName = #"two";
// NSLog(#"%#", indexPath);
}
if (indexPath.section == 2) {
_detailViewController.imageName = #"three";
// NSLog(#"%#", indexPath);
}
//} <--- get rid of this bracket since the original if () was commented out
[self.navigationController pushViewController:self.detailViewController animated:YES];
}
It sounds like you aren't ever releasing your instance of UIScrollView. So, when you go to reuse it the second time, viewDidLoad doesn't get called again. That means your 'image' variable never gets reassigned a new image.
To check to see if this is the case, try putting an NSLog call in your viewDidLoad method and see if it gets called the second time you select from the tableViewCell.
If this is the case, there are a few options for fixing it. Are you using ARC?
Have you tried just updating the UIImageView?
- (void)loadImage:(NSString *)myImageName
{
if (myImageName == #"one") {
imageName = myImageName;
}
if (myImageName == #"two") {
imageName = myImageName;
}
if (myImageName == #"three") {
imageName = myImageName;
}
[image setImage:[UIImage imageNamed:imageName];
}

adding a uinavigationcontroller to a view as part of a stack of uiviews

In my iphone app, I first call a controller which stack up a few view controllers based on index. This is done cause based on the user's selection, i will need to show different screens (basically, i have a welcome screen, tabbar view - which is the main app, sign in and sign up pages). As of now, everything works perfectly - I stack them up and remove / switch based on the need. The problem is that i would like to add a nav bar to both the sign in and sign up views. However, when i do that, something weird happens - i see a nav bar, but on TOP of it, there is a white bar as well (half width more or less). How can i add this uinavbar successfully?
Here is the controller that is being called by the AppDelegate:
- (void)viewDidLoad
{
[super viewDidLoad];
myTabBarVC = [[tabBarController alloc] initWithNibName:#"tabBarController" bundle:nil];
[self.view insertSubview:myTabBarVC.view atIndex:0];
myLoginVC = [[loginViewController alloc] initWithNibName:#"loginViewController" bundle:nil];
[self.view insertSubview:myLoginVC.view atIndex:1];
mySignUp = [[SignUpView alloc] initWithNibName:#"SignUpView" bundle:nil];
[self.view insertSubview:mySignUp.view atIndex:2];
myWelcomeView = [[WelcomeView alloc] initWithNibName:#"WelcomeView" bundle:nil];
[self.view insertSubview:myWelcomeView.view atIndex:3];
}
When I add that to one of the view controllers in this same method, it doesnt work, as described above.
myLoginVC = [[loginViewController alloc] initWithNibName:#"loginViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myLoginVC];
[self.view insertSubview:navController.view atIndex:1];
How can I make it work? Please help. Thanks!
ADDING MORE INFO ABOUT THE VIEW WHERE THE KEYBOARD IS ON BY DEFAULT:
- (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:#"Cell"];
cell.textLabel.text = [[NSArray arrayWithObjects:#"",#"",nil]
objectAtIndex:indexPath.row];
if (indexPath.row == 0) {
textField1 = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 280, 21)];
textField1.delegate = self;
textField1.placeholder = #"example#EMAIL.com";
textField1.text = [inputTexts objectAtIndex:indexPath.row/2];
textField1.tag = indexPath.row/2;
cell.accessoryView = textField1;
textField1.returnKeyType = UIReturnKeyNext;
textField1.clearButtonMode = UITextFieldViewModeWhileEditing ;
[textField1 becomeFirstResponder];
textField1.tag = 1;
}
else
{
textField2 = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 280, 21)];
textField2.delegate = self;
textField2.placeholder = #"password";
textField2.text = [inputTexts objectAtIndex:indexPath.row/2];
textField2.tag = indexPath.row/2;
textField2.returnKeyType = UIReturnKeyDone;
textField2.clearButtonMode = UITextFieldViewModeWhileEditing;
cell.accessoryView = textField2;
[textField1 becomeFirstResponder];
textField1.tag = 2;
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
I don't think you should be adding navController.view as a subview to your view controller. I suspect that's a source of the trouble. Instead use a UINavigationBar object.
With regards to your second question, if it was a question and not a remark, about the keyboard being by default, that happens because you set your textField1 as first responder.

can i display alert view with the table view with segmented controls in every cell

i want to display the table view in alert view. This table view contains segmented control.
these segmented controls are for on/off the audio, image, text. so there will be 3 cells with segmented controls.
how to do this
please help me out
Thank u
Adding UISegmentedControls (or UISwitches, which I would personally recommend for a simple on/off option) is easy enough to put in table view cells using the accessoryView property.
Your view controller (or whatever object you're using to control this thing) must implement the UITableViewDataSource protocol.
#interface MyViewController : UIViewController<UITableViewDataSource, UITableViewDelegate> {}
#end
Add the controls in tableView:cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString* const SwitchCellID = #"SwitchCell";
UITableViewCell* aCell = [tableView dequeueReusableCellWithIdentifier:SwitchCellID];
if( aCell == nil ) {
aCell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:SwitchCellID] autorelease];
aCell.textLabel.text = [NSString stringWithFormat:#"Option %d", [indexPath row] + 1];
aCell.selectionStyle = UITableViewCellSelectionStyleNone;
UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero];
aCell.accessoryView = switchView;
[switchView setOn:YES animated:NO];
[switchView addTarget:self action:#selector(soundSwitched:) forControlEvents:UIControlEventValueChanged];
[switchView release];
}
return aCell;
}
Or, if you're set on segmented controls, replace the UISwitch stuff above with something like:
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:#"On", #"Off", nil]];
segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleWidth;
segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;
segmentedControl.frame = CGRectMake(75, 5, 130, 30);
segmentedControl.selectedSegmentIndex = 0;
[segmentedControl addTarget:self action:#selector(controlSwitched:) forControlEvents:UIControlEventValueChanged];
aCell.accessoryView = segmentedControl;
[segmentedControl release];
I would personally put these options in a regular view (probably accessible from an options button which does the flip transition, like many iPhone apps do). I don't think putting it in an alert view is a very good user experience.
However, I have written a few blog posts showing how to put various views into alert views (text field, which is kinda useful, and web view, which is arguably not).
So, if you're really dead set on putting this in an alert view, you can totally do that, like this:
- (void) doAlertWithListView {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Preferences"
message:#"\n\n\n\n\n\n\n"
delegate:self
cancelButtonTitle:#"Cancel"
otherButtonTitles:#"OK", nil];
UITableView *myView = [[[UITableView alloc] initWithFrame:CGRectMake(10, 40, 264, 150)
style:UITableViewStyleGrouped] autorelease];
myView.delegate = self;
myView.dataSource = self;
myView.backgroundColor = [UIColor clearColor];
[alert addSubview:myView];
[alert show];
[alert release];
}
It will look something like this:
The answer above works great, but on the iPad the line myView.backgroundColor = [UIColor clearColor];
doesn't seem to remove the grey rectangular area around the table. I find that the following does the job: tableView.backgroundView.alpha = 0.0;