2011-04-06 37 views
0

我有这样的enter image description here无法点击一个UIButton这是对视图的右上方推后下一个视图

由tableview中的视图和一个UIButton当我点击“添加”一个名为“Locsetting”的新班级/ xib应该打开,但我无法做到。 我的代码:.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]; 

} 

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

+0

@DavidM!感谢编辑 – Alok 2011-04-06 11:31:12

回答

0

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

+0

谢谢!IbAction没有连接。问题解决了。但是你在说什么“我认为最好有IBOutlet UIButton * addbutton;单独和@property(nonatomic,retain)UIButton * addbutton;” 。我不明白。 – Alok 2011-04-06 11:27:14

+0

我的意思是你只需要将它们中的任何一个作为IBOutlet而不是两者 – visakh7 2011-04-06 11:36:31

1

在快看,有可能是以下3个问题之一:

  1. 是您的IBAction为链接到该按钮的出路何在?

  2. 如果不是,请尝试删除LocSetting *locSetting;及其属性/合成。接下来,那里更改行:Locsetting *locSetting = [[LocSetting alloc] initWithNibName:@"LocSetting" bundle:nil];

  3. 如果还是不行,请尝试更改,为:Locsetting *locSetting = [[LocSetting alloc] initWithNibName:nil bundle:nil];

+0

非常感谢你!我解决了这个问题,但我接下来要玩的选项2和3中给你的技巧。 – Alok 2011-04-06 11:29:24

+0

@Maddy是的,与nibnames一起玩,有一个相当逻辑的背后。好东西你发现错误! ^^ – Joetjah 2011-04-06 11:41:17

相关问题