Problems with iOS GUI

Status
Not open for further replies.
1) hideKeyboard (below) does not hide keyboard. I verified that the view it receives is a text field.

Code:
UIView* findFirstResponder(UIView* start)
{
    if (start.isFirstResponder) 
	{
        return start;     
    }
    for (UIView *subView in start.subviews)
	{
		UIView* ret = findFirstResponder(subView);
        if (ret)
		{
            return ret;
		}
    }
	return nil;
}

void hideKeyboard()
{
	UIView* v = findFirstResponder(gMainView);
	[v resignFirstResponder];
}

2) I have a table in a nav controller in another view I call "main view". The main view is fully occupied by the nav controller.
The table should show numbers 0 through 49, but goes to 38. It tries to scroll further, but bounces back.

Code:
#import "TestTable.h"

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 50;
}

-(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"TestTable"];
	if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"TestTable"];
    }
	cell.textLabel.text = [@"" stringByAppendingFormat:@"%lu", indexPath.row];
	return cell;
}
@end
 
JamesW":373z31mq said:
1) Any reason why [start endEditing:YES] wouldn't work?

1) It's not recursive. Recursivity gives you sixty spiffy points.

2) It only helped when I used the method directly on the text box. There's a situation where I can do that (UITextFieldDelegate), but also others where I can't. Anyway, resignFirstResponder is supposed to work...

I'm not putting text boxes in table cells. I suppose the thing to do in that case would be to add an extra, empty cell. Can you do that after table creation? Or change the content size, since a table is a scroll view?

Currently, I'm working through the process of "take it apart and put it back together, adding pieces until it breaks again". Horribly annoying, but what else am I supposed to do?

UPDATE: the problem with the table was that the view object of the nav controller was bigger than the screen. I set its size, and it scrolls all the way now. I suppose what happened was, it scrolled all the way, but the 49 was outside the screen.
 
Status
Not open for further replies.