私はインターネットから画像をロードしたUIWebViewを持っています。 UIWebViewでこの写真をつぶすオプションを与えるためにUIActionSheetを開くボタンがあります。 UIActionSheetでTweetを押すと、それが消えてUIWebviewが再度表示されます。バックグラウンドでは、画像がインターネットからロードされてツイートに添付されます。これは、画像サイズに応じて数時間かかることがあります。 私は今、彼が何が起こっているのか知っているユーザーのための情報を表示したいと思います。ユーザーがTwitterconsoleが表示されるのを待っている間にMBProgressHUDを表示したい。 ボタンを押してUIActionSheetが消えてもHUDを起動しようとしましたが、起動しませんでした。 Twitterconsoleが表示されたら、バックグラウンドで表示されます。これは少し遅れています。 HUDを開始/停止するのに最適な場所は何ですか? おかげMBProgressHUD表示Twitter
- (void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0)
{
[self hudTweet];
[self tweet];
}
- (void) tweet {
if ([TWTweetComposeViewController canSendTweet])
{
TWTweetComposeViewController *tweetSheet =
[[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:
@"Tweeting from "];
NSString *fullURL = beverageViewString;
NSURL *url = [NSURL URLWithString:fullURL];
NSString *paths = NSTemporaryDirectory();
NSError *error;
if (![[NSFileManager defaultManager] fileExistsAtPath:paths])
[[NSFileManager defaultManager] createDirectoryAtPath:paths withIntermediateDirectories:NO attributes:nil error:&error];
NSString *filePath = [paths stringByAppendingPathComponent:[self.title stringByAppendingFormat:@".jpeg"]];
NSData *jpegFile = [NSData dataWithContentsOfURL:url];
[jpegFile writeToFile:filePath atomically:YES];
[tweetSheet addImage:[UIImage imageWithContentsOfFile:filePath]];
[self presentModalViewController:tweetSheet animated:YES];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Sorry"
message:@"You can't send a tweet right now because your account isn't configured"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
- (void) hudTweet {
HUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow];
[self.view.window addSubview:HUD];
HUD.delegate = self;
HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
HUD.labelText = @"Loading";
HUD.detailsLabelText = @"updating data";
}
どのビューにMBProgressHUDを追加していますか?しかし、あなたのコードを見るのに役立ちます。 – FluffulousChimp
あなたに役立つコードを表示する必要があります。 –
上記のコードをご覧ください!ありがとう – halloway4b