导航栏按钮不可点击

时间:2011-12-02 10:51:43

标签: objective-c ios

我添加了这个导航条形码,但我无法点击左侧的lat项目按钮“编辑”,当我用文本框替换时,即使这也不起作用(不取值),如果你能搞清楚这段代码有什么问题,我将非常乐于助你。

谢谢,

Aashish

找到屏幕截图 http://www.flickr.com/photos/71234685@N02/6440926473/in/photostream

-(void) initializeNavigationalBar {

UIToolbar* _leftNavBarTools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 300, 44.01)];

// create the array to hold the buttons, which then gets added to the toolbar

NSMutableArray* _leftNavBarButtons = [[NSMutableArray alloc] initWithCapacity:4];

UIBarButtonItem* _editScenarioProduct = self.editButtonItem;

UIBarButtonItem* _addTurftype = [[UIBarButtonItem alloc] initWithTitle:@"Turftype" style:UIBarButtonItemStyleBordered target:self action:@selector(getTurfType)];

UIBarButtonItem *_addTargetN = [[UIBarButtonItem alloc] initWithTitle:@"Target N" style:UIBarButtonItemStyleBordered target:self action:@selector(getTargetNperWeek)];

UIBarButtonItem *_addMapRegion = [[UIBarButtonItem alloc] initWithTitle:@"Map Region" style:UIBarButtonItemStyleBordered target:self action:@selector(getMapRegion)];

CGRect _textFrame = CGRectMake(0, 0, 80, 30 );
_turfacresTextField = [[UITextField alloc] initWithFrame:_textFrame];
_turfacresTextField.borderStyle = UITextBorderStyleRoundedRect;
_turfacresTextField.font = [UIFont systemFontOfSize:12.0];
_turfacresTextField.placeholder = @"Turf Acres";
_turfacresTextField.textAlignment = UITextAlignmentCenter;
_turfacresTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
_turfacresTextField.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
_turfacresTextField.keyboardType = UIKeyboardTypeDefault;
_turfacresTextField.returnKeyType = UIReturnKeyDone;

UIBarButtonItem *_addTurfacres = [[UIBarButtonItem alloc] initWithCustomView:_turfacresTextField]; 

[_leftNavBarButtons addObject:_addTurftype];
[_leftNavBarButtons addObject:_addTargetN];
[_leftNavBarButtons addObject:_addMapRegion];
[_leftNavBarButtons addObject:_addTurfacres];
[_leftNavBarButtons addObject:_editScenarioProduct];

[_leftNavBarTools setItems:_leftNavBarButtons animated:NO];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_leftNavBarTools];

UIToolbar* _rightNavBarTools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 200, 44.01)];

// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* _rightNavBarButtons = [[NSMutableArray alloc] initWithCapacity:4];

UIBarButtonItem *_addSoilSetting = [[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStyleBordered target:self action:@selector(setSoilandCarryover)];
[_rightNavBarButtons addObject:_addSoilSetting];

 UIBarButtonItem* _addApplication = [[UIBarButtonItem alloc] initWithTitle:@"Add Appplication" style:UIBarButtonItemStyleBordered target:self action:@selector(addApplication)];

[_rightNavBarButtons addObject:_addApplication];

[_rightNavBarTools setItems:_rightNavBarButtons animated:NO];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_rightNavBarTools];
}

1 个答案:

答案 0 :(得分:0)

尝试[self editButtonItem]而不是self.editButtonItem。