Я использую контроллер вкладок, один из контроллеров представлений имеет табличное представление. Я использую QBSimpleSyncRefreshControl для обновления по запросу, он отлично работает при первой загрузке контроллера вкладок, когда я выхожу из системы, я перезагружаю свой контроллер вкладок (контроллер корневого представления), который приложение времени неожиданно зависло.
Это код, который я использую
в табличном контроллере
QBSimpleSyncRefreshControl *refreshControl = [[QBSimpleSyncRefreshControl alloc] init];
refreshControl.delegate = self;
self.myRefreshControl = refreshControl;
[self.tvTableView addSubview:self.myRefreshControl];
я сделал при выходе из системы
UIStoryboard *board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UINavigationController *Tabctrl = [board instantiateViewControllerWithIdentifier:@"vcInitialViewNavId"];
UIWindow *window = AppDelegate.window;
[window addSubview:Tabctrl.view];
window.rootViewController = Tabctrl;
Если я заблокирую эту линию
[self.tvTableView addSubview:self.myRefreshControl];
Приложение работает нормально, если разблокировать это приложение, происходит сбой при выходе из системы (перезагрузите контроллер корневого представления)
Может ли кто-нибудь помочь в этом.
Полный код здесь:
Файл view.h
@interface MyTCView : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate, QBRefreshControlDelegate>
{
// some declaration here
}
@property (weak, nonatomic) IBOutlet UITableView *tvTableView;
@property (nonatomic, strong) QBSimpleSyncRefreshControl *myRefreshControl;
вид.м
- (void)viewDidLoad
{
[super viewDidLoad];
FeaturedItemTitle = @"";
HUD = [[MBProgressHUD alloc] initWithView:self.view];
HUD.mode = MBProgressHUDModeIndeterminate;
[self.view addSubview:HUD];
AppDelegate = (TCAppDelegate *) [UIApplication sharedApplication].delegate;
board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
QBSimpleSyncRefreshControl *refreshControl = [[QBSimpleSyncRefreshControl alloc] init];
refreshControl.delegate = self;
self.myRefreshControl = refreshControl;
[self.tvTableView addSubview:self.myRefreshControl];
}
- (void)refreshControlDidBeginRefreshing:(QBRefreshControl *)refreshControl
{
[self GetDetails];
}
-(void) GetDetails
{
// Calling web service here
NSString *strURL = @"URL HERE";
NSURL *url = [NSURL URLWithString: strURL];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest setHTTPMethod:methodType];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:delegate];
if ( theConnection ) {
//Connection successful
receivedData = [NSMutableData data];
} else {
//Failure
NSLog(@"Error");
}
}
//*** HTTP Connection ***//
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
receivedData = [[NSMutableData alloc] init];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[receivedData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
[HUD hide:YES];
[self ShowAlertMessage:ServerErrorMsg Tilte:@""];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSError *error;
NSDictionary *res = [NSJSONSerialization JSONObjectWithData:receivedData options:NSJSONReadingAllowFragments error:&error];
// Array of data get from Res(NSDictionary)
[tvTableView reloadData]; // Tableview Reload
[collView reloadData]; // Collectionview reload
[self.myRefreshControl endRefreshing];
[HUD hide:TRUE];
}