iPhoneアプリでactivityIndicatorを処理しようとしています。
しかし、それはまったく機能しません。
プロジェクト内にUISearchbarがあります。
ユーザーがキーワードを入力してクリックすると、UIWEbviewに文字列が表示されます。
データを待っている間はアクティビティインジケーターを表示してアニメーション化し、データが読み込まれると停止するようにします。
これが私が使用するコードの一部です:
@implementation myFirstappController
@synthesize myWebview, activityIndicator;
- (void)webViewDidStartLoad:(UIWebView *)myWebview
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[activityIndicator startAnimating];
}
- (void)webViewDidFinishLoad:(UIWebView *)myWebview
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[activityIndicator stopAnimating];
}
///Here is code inside the UISearchbar
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
NSString *keywords = searchBar.text;
NSString *infos = [NSString stringWithFormat: @"%@", keywords];
NSString *rs=nil;
if ([infos isEqualToString:@"Iloveyou"]){
rs =@"<span style='color:#3B5998; font-size:25px;font-weight: bold;'>I love you too </span> <span style='color:#666; font-size:18px;'> -rte,-rt </span> ;
[myWebview loadHTMLString:rs baseURL:nil];
}
- (void)dealloc {
[myWebview release]; //<-------JUST FILL THIS LINE**********************
[activityIndicator release];
[searchBar release];
[super dealloc];
}
@end