UITableView cannot scroll
I created a very simple view trying to combine a navigation controller and table view together:
.h
interface FileView : UIView {
UINavigationController * _nav;
UITableV开发者_JAVA技巧iewController * _tableView;
}
.m
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
_tableView = [[FileTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
_nav = [[UINavigationController alloc]initWithRootViewController:_tableView];
[self addSubview:_nav.view];
}
return self;
}
Then, to my surprise, when I added this view into the main window. I found the tableview simply didn't scroll, and table cells didn't respond to any events. It looked like the table view was hidden't under some glass.
Anyone knows how to solve the issue? and what step I missed to make it work?
Thanks a lot!
Try adding this line after adding the subview:
[self bringSubviewToFront:_nav.view];
Thanks, Problem solved. When creating the FileView, I need to provide a Frame, which I didn't :)
精彩评论