单击视图右上角的uibutton后无法推送下一个视图

时间:2011-04-06 11:05:26

标签: iphone

我有一个由tableview和这样的uibutton组成的视图enter image description here

当我点击按钮“添加”时,一个名为“Locsetting”的新类/ xib应该是open.which我无法做到。 我的代码:.h文件

    @interface LocationViewController : UIViewController     <UITableViewDelegate,UITableViewDataSource>    
 {  
    UITableView *table;    
    NSMutableArray *menuList;  
    LocSetting *locSetting;  
    IBOutlet UIButton *addbutton;  
}

@property (nonatomic,retain) NSMutableArray *menuList;  
@property (nonatomic,retain) IBOutlet UITableView *table;  
@property (nonatomic,retain) LocSetting *locSetting;  
@property (nonatomic, retain) IBOutlet UIButton *addbutton;  
-(IBAction)gotoLocSetting:(id) sender;  
@end

  My .m :    

@synthesize addbutton;  
-(IBAction)gotoLocSetting:(id) sender    {
    NSLog(@"gotoLocSetting Entered");  
    locSetting = [[LocSetting alloc]
                  initWithNibName:@"LocSetting"
                  bundle:nil];  
    //locationViewController.menuList = [menuList objectAtIndex:indexPath.row];  
    [self.navigationController pushViewController:locSetting
                                         animated:YES];  
    [locSetting release];  

}

我在做什么错?或者请指导我! 感谢

2 个答案:

答案 0 :(得分:1)

快速查看,可能存在以下3个问题之一:

  1. 您的IBAction是否与按钮的插座相关联?

  2. 如果没有,请尝试删除LocSetting *locSetting;及其属性/合成。接下来,将您的行更改为:Locsetting *locSetting = [[LocSetting alloc] initWithNibName:@"LocSetting" bundle:nil];

  3. 如果不起作用,请尝试将其更改为:Locsetting *locSetting = [[LocSetting alloc] initWithNibName:nil bundle:nil];

答案 1 :(得分:0)

确保IBAction正确连接到按钮。我认为单独IBOutlet UIButton *addbutton;@property (nonatomic, retain) UIButton *addbutton;

会更好