不工作我使用這些代碼自定義後退按鈕定製後退按鈕在Xcode
UIImage *buttonImage = [UIImage imageNamed:@"back-button-2.png"];
//create the button and assign the image
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];
//set the frame of the button to the size of the image (see note below)
button.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
[button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
//create a UIBarButtonItem with the button as a custom view
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = customBarItem;
這裏是回功能
-(void)back {
// Tell the controller to go back
[self.navigationController popViewControllerAnimated:YES];
}
自定義後退按鈕快到了,但它不工作。
會發生什麼事,當你點擊按鈕?它是否像普通的酒吧按鈕一樣暗淡?或者它沒有反應? –
它顯示正常Tab鍵,但不重定向。 – Shyantanu
你嘗試使用' - (void)返回:(id)sender'並添加動作爲'@selector(back:)' –