必须抓住';我没事UIView超过UITableView未接收分接头

必须抓住';我没事UIView超过UITableView未接收分接头,uitableview,uiview,ios,Uitableview,Uiview,Ios,此应用程序的问题是TapCatchingController没有接收到这些点击 位于节标题上或节之间的。我想知道我该怎么做。 我试着让我的示例程序尽可能小,但它仍然很长, 对不起。然而,代码是独立的。如果你复制并粘贴到你的 AppDelegate,你应该可以走了!:) 提前感谢,, --尼克 #导入 //----------------------------------------------------------------------------------------------- /

此应用程序的问题是TapCatchingController没有接收到这些点击 位于节标题上或节之间的。我想知道我该怎么做。 我试着让我的示例程序尽可能小,但它仍然很长, 对不起。然而,代码是独立的。如果你复制并粘贴到你的 AppDelegate,你应该可以走了!:)

提前感谢,, --尼克

#导入
//-----------------------------------------------------------------------------------------------
//类InfiniteView控制器:当点击视图时,表示用户看不到视图
@接口TapCatchingViewController:UIViewController{}@end
@TapCatchingViewController的实现
-(void)负荷视图{
self.view=[[UIView alloc]init];
self.view.alpha=1.0;
}
-(void)touchesend:(NSSet*)toucheevent:(UIEvent*)event{NSLog(@“您点击了这个!Tuhm dududu dum”);}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{返回YES;}
-(void)视图将消失:(BOOL)动画{[super-viewwilldefine:animated];}
@结束
//-----------------------------------------------------------------------------------------------
//类SuperViewController:一个在其上面有InfiniteViewController视图的表视图
//在SuperViewController视图上的任何点击都应通过InfiniteViewController
@界面SuperViewController:UITableViewController{
点击CatchingViewController*vc;
}
@结束
静态常数int段=7;
静态常量int rowsPerSection=9;
@实现SuperViewController
-(无效)viewDidLoad{
vc=[[TapCatchingViewController alloc]init];
vc.view.frame=CGRectInfinite;
[self.view addSubview:vc.view];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView{return sections;}
-(NSInteger)tableView:(UITableView*)tableView行数节:(NSInteger)节{return rowsPerSection;}
-(NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section{return@“section Header”;}
-(CGFloat)tableView:(UITableView*)headerinsection:(NSInteger)section{return 250.0f;}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
静态NSString*CellIdentifier=@“Cell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil)cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier]自动释放];
cell.textlab.text=@“喵喵,喵喵。”;
返回单元;
}
-(void)tableView:(UITableView*)tableView DidSelectRowatineXpath:(NSIndexPath*)indexPath{}
-(无效)解除锁定{
[vc dealloc];
[super dealoc];
}
@结束
//-----------------------------------------------------------------------------------------------
//类AppDelegate!通常的东西:)
@InfiniviewsAppDelegate接口:NSObject{
UIWindow*窗口;
UIViewController*vc;
}
@属性(非原子,保留)IBUIWindow*window;
@结束
@InfiniviewsAppDelegate的实现
@合成窗口;
-(BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项{
vc=[[SuperViewController alloc]initWithStyle:UITableViewStyleGroup];
[窗口添加子视图:vc.view];
[WindowMakeKeyandVisible];
返回YES;
}
-(void)applicationWillResignActive:(UIApplication*)应用程序{}
-(void)applicationIDBecomeActive:(UIApplication*)应用程序{}
-(无效)应用程序将终止:(UIApplication*)应用程序{}
-(无效)应用程序IDReceiveMemoryWarning:(UIApplication*)应用程序{}
-(无效)解除锁定{
[vc发布];
[窗口释放];
[super dealoc];
}
@结束

我不确定是否理解您的问题,但是 我能看到的唯一问题是viewController的视图添加了
[self.view addSubview:vc.view]但不能保证它始终位于窗口顶部

可能缺少的代码行是
[self.view bringsubview-tofront:vc.view]

但是,您可以通过对
vc.view

我仍然无法理解您的目标,为什么要在
TableViewController
子类中添加视图控制器的视图

希望对你有帮助

#import <UIKit/UIKit.h>

//-----------------------------------------------------------------------------------------------
//Class InfiniteViewController: Says something when view is tapped, view is invisible to the user
@interface TapCatchingViewController : UIViewController {} @end
@implementation TapCatchingViewController
- (void) loadView {
    self.view = [[UIView alloc] init];
    self.view.alpha = 1.0;
}

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"You tapped this! Tuhm-dudu-dum"); }
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; }
- (void) viewWillDisappear:(BOOL)animated { [super viewWillDisappear: animated]; }
@end

//-----------------------------------------------------------------------------------------------
//Class SuperViewControoler: A tableview who has on top of it an InfiniteViewController's view
//Any tap on a SuperViewController's view should pass through the InfiniteViewController
@interface SuperViewController : UITableViewController {
    TapCatchingViewController * vc;
}
@end

static const int sections = 7;
static const int rowsPerSection = 9;

@implementation SuperViewController
- (void) viewDidLoad {
    vc = [[TapCatchingViewController alloc] init];
    vc.view.frame = CGRectInfinite;
    [self.view addSubview: vc.view];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return sections; }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return rowsPerSection; }
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return @"Section Header"; }
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 250.0f; }

- (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:CellIdentifier] autorelease];
    cell.textLabel.text = @"Meow, meow.";
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {}

- (void)dealloc {
    [vc dealloc];
    [super dealloc];
}
@end

//-----------------------------------------------------------------------------------------------
//Class AppDelegate! The usual stuff :) 
@interface InfiniviewsAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    UIViewController * vc;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@end

@implementation InfiniviewsAppDelegate
@synthesize window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    vc = [[SuperViewController alloc] initWithStyle: UITableViewStyleGrouped];
    [window addSubview: vc.view];
    [window makeKeyAndVisible];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {}
- (void)applicationDidBecomeActive:(UIApplication *)application {}
- (void)applicationWillTerminate:(UIApplication *)application {}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {}
- (void)dealloc {
    [vc release];
    [window release];
    [super dealloc];
}
@end