我通常創建的UIImageView,然後UITapGestureRecognizer和我添加它來UIImageView,最後我創建UIBarbuttonItem:
//UIImageView where the image is shown
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageName"]];
imageViewSettings.frame = CGRectMake(0, 0, 25, 25);
imageViewSettings.contentMode = UIViewContentModeScaleAspectFit;
//TapGesture
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(methodToTrigger)];
//Adding the gesture to the ImageView
[imageView addGestureRecognizer:tapGesture];
//Creating the barButtonItem
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:imageView];
//Finally add the button to the navigationBar
self.navigationItem.rightBarButtonItem = barButtonItem;
你是什麼意思「修復屏幕」?屏幕頂部的 – 2011-03-24 13:05:24
已經看到了註冊按鈕。在屏幕截圖中,我正在獲得空白。請引導我解決它。 – girish 2011-03-24 13:07:30