我是iPhone编程的新手。我已经通过fbgraph API将facebook集成到了我的应用程序中。我的意图是在我的应用程序中单击Facebook按钮时显示活动指示器。
最佳答案
您必须在.H文件中使用NSURLRequest和NSURLConnection以及UIActivityIndicatorView和NSData对象。
NSURLRequest *theRequest;
NSURLConnection *theConnection;
IBOutlet UIActivityIndicatorView *myIndicator;
NSMutableData *receivedData;
}
@property (nonatomic, retain) NSMutableData *receivedData;
@property (nonatomic,retain) IBOutlet UIActivityIndicatorView *myIndicator;
.m文件
@synthesize youTubeWebView,receivedData,myIndicator;
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[receivedData appendData:data];
}
- (void)viewDidLoad {
[super viewDidLoad];
[myIndicator startAnimating];
myIndicator.hidesWhenStopped = YES;
// Now your code of fb integration
NSURLRequest requestWithURL:url;
theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
receivedData = [[NSMutableData data] retain];
}
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
// code after Loading of fb page
[myIndicator stopAnimating];
}
希望所有这些对您有所帮助:))