簡體   English   中英

向ABUnknownPersonViewController添加自定義按鈕

[英]Add a custom button to ABUnknownPersonViewController

我正在使用ABUnknownPersonViewController來顯示UINavigatonController中的聯系信息,並且我希望在底部有一個按鈕,該按鈕可以推送另一個具有該用戶其他信息的viewController。 我已經能夠在底部添加一個按鈕,並且可以向下滾動並查看它,但是它不會停留在屏幕上。

我正在尋找相同的東西,但是能否請您告訴我您如何在底部添加按鈕?

我所做的是在導航欄頂部的頂部添加了一個按鈕,盡管它確實存在一些視覺問題,但這是我的方法。



//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];

我希望這可以在某種程度上幫助您...

- (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];
}

我用來將按鈕添加到底部的代碼,但是一旦滾動到它,它就不會停留在視圖中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM