我尝试用UIImage设置右键项目:
它推动UINavbar(它是IBOutlet并在故事板中使用)左键和右键,我以编程方式创建。左按钮工作正常而不是右按钮似乎没有初始化。
在标题中:
@property (weak, nonatomic) IBOutlet UINavigationBar *navBar;
我尝试的是:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture", self.userDestFBID]];
NSData *imageData = [NSData dataWithContentsOfURL:url];
UIImage *destProfileImage = [UIImage imageWithData:imageData];
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithImage:_destProfileImage style:UIBarButtonItemStyleDone target:self action:@selector(goBack)];
_item = [[UINavigationItem alloc] initWithTitle:nil];
_item.hidesBackButton = YES;
_item.leftBarButtonItem = activityItem;
_item.rightBarButtonItem = rightButton;
[_navBar pushNavigationItem:_item animated:YES];
任何帮助将不胜感激..
答案 0 :(得分:0)
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:_destProfileImage] forState:UIControlStateNormal];
[button addTarget:self action:@selector(action:)forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(0, 0, 50, 30)];
_item = [[UINavigationItem alloc] initWithTitle:nil];
_item.hidesBackButton = YES;
_item.leftBarButtonItem = activityItem;
_item.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
;
[_navBar pushNavigationItem:_item animated:YES];