UIWebViewでBASIC認証のページを見る時

UIWebViewでアクセスURLやアクセス先のLINK内にBasic認証がかかっているとページの読み込み中になりっぱなしで画面が真っ白いままになってしまいます。

http://user:password@domain.com/みたいな形で、暫定対応はできますが、
アクセス先ページ内のLINKが認証かかっていたら、同じ結果です。

BASIC認証先のID/PWが解っている場合は、NSURLCredentialを使って、あらかじめ登録しておく事で対応できます。
ただID/PASSWORDだけでなく、realmまで知っておく必要があります。

realmは HTTP Response HeaderのAuthenticate: Basicの項目で確認できます。


Access to basic authorization page by UIWebview.

The page content is empty and continues loading accessing to page protected by Basic Auth with UIWebview.
If you know the ID/Password on that page, using NSURLCredential and solute this problem.
this code.

To know realm seeing HTTP Response Header 'Authenticate: Basic realm="realm"'

		
NSURLCredentialStorage *storage = [NSURLCredentialStorage sharedCredentialStorage];
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"USER"
password:@"PASSWORD"
persistence:NSURLCredentialPersistenceForSession];
NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:@"www.domain.com"
port:80
protocol:@"http"
realm:@"Authorization required"
authenticationMethod:NSURLAuthenticationMethodHTTPBasic];
[storage setCredential:credential
forProtectionSpace:protectionSpace];

UIViewController とUITableViewControllerを両方継承したい場合

例えばUIViewControllerとUITableViewControllerに対して共通の処理を実装したい場合には、どうすれば良いかという話。

まず、ObjectiveCは多重継承を許していません。
本来であれば、TableViewのviewForHeaderとかviewForFooterを巧く使えればベストですが、
UITableViewControllerを使用するのを止めて、UIViewController+UITableViewの構成にし、tableView自体をproperyで持つ事でクリアできるかと思います。

言ってみれば、疑似UITableViewControllerですね。
この場合、UIViewDidScrollなどのUIScrollViewのDelegateメソッドも取得できないので、その辺も要注意。
(プルダウン更新を実装する時とか、問題が残ります。ex EGORefreshTableHeaderView)


How do I add same logic on UITableViewController And UIViewController?

Then Objective-c doesn't allow multi inheritance.
Of course we want to avoid double maintenance.
So It is best way is using only UITableViewcontroller's tableheaderview and tablefooterview. But that way isn't suitable in some situation.

So I made the inheritance of UIViewController that has tableview propery.
This way is avaiable to access self.tableView.

But in this case some problems remain that cannnot catch UIViewScroll's delegate message.
for example this way doesn't work binding EGORefreshTableHeaderView.