2013-01-01 23 views
1

我想使我的網站視圖頂部地址欄和底部欄按鈕,如Safari瀏覽器,我用safari代替網頁視圖,但我不能自定義大小safari,實際上我想在底部顯示tabbar,我通過在另一個視圖中添加Safari瀏覽器,然後添加到我的主視圖作爲子視圖,但總是我的標籤欄隱藏在瀏覽器後面,所以我想在我的web視圖中顯示它像這樣enter image description here如何顯示帶有地址欄和底部工具欄按鈕的webView像safari

任何人都可以幫我嗎?

+0

你好,我是使應用程序看起來像野生動物園,我想知道如何使用Safari瀏覽器webview花邊?非常感謝! – Suge

回答

1

試試這個代碼

[webview goFarward]; 
[webview goBack]; 
1

您需要構建複合視圖並編寫代碼以將所有內容(webview,按鈕,地址欄,搜索欄)粘合在一起。

編輯:添加小例子:

FullWebView.h:

#import <UIKit/UIKit.h> 

@interface FullWebView : UIView 

@end 

FullWebView.m:

#import "FullWebView.h" 

@interface FullWebView() 
@property (nonatomic, retain) UIWebView* webView; 
@end 

@implementation FullWebView 

- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     [self setup]; 
    } 
    return self; 
} 

- (id)initWithCoder:(NSCoder *)aDecoder 
{ 
    self = [super initWithCoder:aDecoder]; 
    if (self) { 
     [self setup]; 
    } 
    return self; 
} 

- (void) setup 
{ 
    UIButton* backButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    backButton.frame = CGRectMake(0, 0, 140, 40); 
    [self addSubview:backButton]; 
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 40, self.bounds.size.width, self.bounds.size.height - 40)]; 
    [self addSubview:self.webView]; 

    //Glue code for back button 
    [backButton addTarget:self action:@selector(backTapped:) forControlEvents:UIControlEventTouchUpInside]; 
} 

- (void) backTapped:(id)sender 
{ 
    [self.webView goBack]; 
} 

@end 
+0

你能舉個例子嗎? – NullData

+0

添加了將後退按鈕和webview粘合在一起的最小示例。結果是一個具有webview和後退按鈕的自定義UIView類。當然你需要的不僅僅是這些。您正在考慮編寫一整天的代碼以獲得可重用的全功能瀏覽器窗口組件。 – sqreept

相關問題