iphone - 左箭头 - UINavigationItem
<p><p>我已经四处寻找,但似乎无法弄清楚。我相信很多人都会为我提供链接等,我很可能已经看过了。但如果有人可以请给我看代码来执行以下操作:</p>
<p>我想在我的 <code>UINavigationBar</code> 中有一个左箭头作为“返回”<code>UINavigationItem</code>。我怎样才能做到这一点?这是我的 <code>UIViewController</code> 中的当前代码:</p>
<pre><code>theBar = [ initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];
UIBarButtonItem *leftButton = [ initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:@selector(backButtonSelected:)];
UIBarButtonItem *rightButton = [ initWithTitle:@"Options" style:UIBarButtonItemStyleBordered target:nil action:@selector(optionsButtonSelected:)];
UINavigationItem *item = [ initWithTitle:@"Title"];
item.leftBarButtonItem = leftButton;
item.hidesBackButton = YES;
item.rightBarButtonItem = rightButton;
;
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我想这可能就是你要找的。</p>
<pre><code>// in .h file
@property (nonatomic, retain) UINavigationBar *navBar;
// in .m file just below @implementation
@synthesize navBar;
// within .m method
navBar = [ initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];
navBar.barStyle = UIBarStyleBlack;
UINavigationItem *title = [ initWithTitle:@"Nav Bar Title"];
UIBarButtonItem *leftButton = [
initWithTitle:@"Back"
style:UIBarButtonItemStylePlain
target:nil
action:@selector(backButtonSelected:)];
title.leftBarButtonItem = leftButton;
UIBarButtonItem *rightButton = [
initWithBarButtonSystemItem:UIBarButtonSystemItemAction
target:nil
action:@selector(showActionSheet:)];
title.rightBarButtonItem = rightButton;
;
;
</code></pre></p>
<p style="font-size: 20px;">关于iphone - 左箭头 - UINavigationItem,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/4596234/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/4596234/
</a>
</p>
页:
[1]