向ABUnknownPersonViewController添加自定义按钮

时间:2011-01-25 02:28:49

标签: iphone ios4

我正在使用ABUnknownPersonViewController在UINavigatonController中显示联系人信息,我想在底部有一个按钮,它将推送另一个viewController,其中包含有关该用户的其他信息。我已经能够在底部添加一个按钮,我可以向下滚动查看它,但它不会停留在屏幕上。

2 个答案:

答案 0 :(得分:0)

我正在寻找同样的事情,但是请你告诉我你是如何在底部添加一个按钮的?

我所做的是在导航栏顶部的顶部添加一个按钮,虽然它确实有一些视觉问题,但这就是我的做法。



//I created a UIToolBar 
UIToolBar *myToolBar = [[UIToolBar alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
//then set the style to match my navBar
[myToolBar setBarStyle:UIBarStyleBlackOpaque];
//and finally created the button.
NSMutableArray *buttons = [NSMutableArray alloc] initWithCapacity:1]autorelease];
UIBarButtonItem *details = [[[UIBarButtonItem alloc] init]autorelease];
[details setTitle: @"details"];

//after that placed it on top of the UPVC unknownPersonViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:myToolBar];

我希望这能以某种方式帮助你......

答案 1 :(得分:0)

- (void)loadView
{
    [super loadView];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button setTitle:@"Horray Button!!" forState:UIControlStateNormal];
    button.frame = CGRectMake(80.0, 500.0, 160.0, 40.0);
    //[self.view addSubview:button];

    NSArray *subviews = [self.view subviews];
    NSLog(@"subviews: %d", [subviews count]);

    UIScrollView *v = [subviews objectAtIndex:0];

    [v addSubview:button];
    CGSize cgSize = [v contentSize];
    cgSize.height = 500.0 + 40.0;
    [v setContentSize:cgSize];
}

我用来在底部添加按钮的代码,但滚动后它不会保留在视图中。