我正在开发一个iPhone应用程序,其中有一个uitableview,当选择表视图中的任何行时,将加载一个新的viewcontroller,显示有关tableview中所选行的详细信息。我的问题是我需要在tableview和详细信息视图中导航栏,导航栏应该有后退按钮,即详细视图上的导航栏应该有一个后退按钮到tableview应该有一个后退按钮到早期的视图控制器。如何我以编程方式执行此操作?
答案 0 :(得分:1)
具有tableview的viewcontroller应该是导航控制器的根视图控制器(您可以以编程方式创建)。然后你只需推(pushviewcontroller:animated :)详细视图控制器。
答案 1 :(得分:1)
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect
{
NSLog(@"self.topItem.title = %@", self.topItem.title);
CGRect frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
UIImage *image = [UIImage imageNamed: @"background.png"];
[image drawInRect:frame];
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
[label setBackgroundColor:[UIColor clearColor]];
label.font = [UIFont boldSystemFontOfSize: 20.0];
//label.shadowColor = [UIColor colorWithWhite:1.0 alpha:1];
label.textAlignment = UITextAlignmentCenter;
label.textColor = RGBCOLOR(73, 81, 85);
label.text = self.topItem.title;
self.topItem.titleView = label;
self.tintColor = RGBCOLOR(229, 239, 246);
}
@end
还将UIButton及其Action事件添加到View Controller之间导航