in my iOS application, I need to use Reachability to complete the following tasks:
When a view controller is rendered, the application needs to check the connection status, and display the connection icon image accordingly (online or offline).
When the user stays on the view controller, and if the internet connection status changes, the application will be notified with the change, and then do some tasks accordingly.
I used the Reachability class which is produced by Tony Million in my application, but a strange thing happened:
After calling the startNotified method, the reachability status changes to 0(NotReachable).
The following is my code:
BTLandingViewController.h
#import <UIKit/UIKit.h>
#import "MBProgressHUD.h"
#import "Reachability.h"
#interface BTLandingViewController : UIViewController <UIAlertViewDelegate>
{
__weak IBOutlet UIImageView *internetIndicator;
MBProgressHUD *hud;
Reachability *reach;
UIAlertView *emptyRecordsAlert;
UIAlertView *syncReminderAlert;
}
#end
Part of the code in
BTLandingViewController.m
#import "BTLandingViewController.h"
#interface BTLandingViewController ()
#end
#implementation BTLandingViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Initialize reachability
reach = [Reachability reachabilityWithHostname:BTReachTestURL];
}
return self;
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// Register with reachability changed notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(reachabilityChanged:)
name:kReachabilityChangedNotification
object:nil];
NetworkStatus internetStatus = [reach currentReachabilityStatus]; // value = 1 or 2
***// PS: If there is connection, before [reach startNotifier], the internetStatus's value reflects the connection status (1 or 2)***
// Start notify reachability change
[reach startNotifier];
internetStatus = [reach currentReachabilityStatus]; // Value = 0;
***// PS: Even if there is connection, after [reach startNotifier], the internetStatus's value becomes 0***
}
Thank you for your help.
I have finally solved this problem by working around the startNotifier trap I mentioned above. Calling startNotifier does change the network status to 0, but I declare a variable to store the initial network status when the view controller is rendered. And then use the value of the variable in a if statement in the method which handles the action triggered by reachabilityChanged notification. The following is my code:
BTLandingViewController.h
#import <UIKit/UIKit.h>
#import "MBProgressHUD.h"
#import "Reachability.h"
#interface BTLandingViewController : UIViewController <UIAlertViewDelegate>
{
__weak IBOutlet UIImageView *internetIndicator;
MBProgressHUD *hud;
NSInteger initialNetworkStatus;
UIAlertView *emptyRecordsAlert;
UIAlertView *syncReminderAlert;
}
#end
BTLandingViewController.m
#import "BTLandingViewController.h"
#import "BTSyncEngine.h"
#import "BTInstructorLoginViewController.h"
#import "BTGlobalParams.h"
#interface BTLandingViewController ()
#end
#implementation BTLandingViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidUnload {
internetIndicator = nil;
[super viewDidUnload];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// Register with sync complete notification
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(syncCompleted:) name:#"BTSyncEngineSyncCompleted" object:nil];
// Register with reachability changed notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(reachabilityChanged:)
name:kReachabilityChangedNotification
object:nil];
Reachability *reach = [Reachability reachabilityWithHostname:BTReachTestURL];
reach.reachableBlock = ^(Reachability * reachability){
dispatch_async(dispatch_get_main_queue(), ^{
initialNetworkStatus = 1;
[internetIndicator setImage:[UIImage imageNamed:#"online_indicator.png"]];
// Start syncing local records with the remote server
[[BTSyncEngine sharedEngine] startSync];
hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = #"Sync in progress";
});
};
reach.unreachableBlock = ^(Reachability * reachability)
{
dispatch_async(dispatch_get_main_queue(), ^{
initialNetworkStatus = 0;
[internetIndicator setImage:[UIImage imageNamed:#"offline_indicator.png"]];
// If the initial sync has been executed
// then use the cached records on the device
if ([[BTSyncEngine sharedEngine] initialSyncComplete]) {
// Go to instructor login screen
BTInstructorLoginViewController *instructorLoginViewController = [[BTInstructorLoginViewController alloc] init];
[instructorLoginViewController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:instructorLoginViewController animated:YES completion:nil];
}
// If the initial sync has not been executed
// show an alert view
else {
emptyRecordsAlert = [[UIAlertView alloc] initWithTitle:#"Alert" message:#"Please connect to the internet to load data for the first time use." delegate:self cancelButtonTitle:nil otherButtonTitles:#"OK", nil];
[emptyRecordsAlert show];
}
});
};
[reach startNotifier];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
// Unregister with reachability changed notification
[[NSNotificationCenter defaultCenter] removeObserver:self name:kReachabilityChangedNotification object:nil];
// Unregister with sync complete notification
[[NSNotificationCenter defaultCenter] removeObserver:self name:#"BTSyncEngineSyncCompleted" object:nil];
}
- (void)syncCompleted:(NSNotification *)note
{
// Update the global sync completed flag
[[BTGlobalParams sharedParams] setSyncCompleted:YES];
// Hide syncing indicator
[MBProgressHUD hideHUDForView:self.view animated:YES];
// Go to instructor login screen
BTInstructorLoginViewController *instructorLoginViewController = [[BTInstructorLoginViewController alloc] init];
[instructorLoginViewController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:instructorLoginViewController animated:YES completion:nil];
}
- (void)reachabilityChanged:(NSNotification *)note
{
Reachability *reach = [note object];
if ([reach isReachable] && !initialNetworkStatus) {
[internetIndicator setImage:[UIImage imageNamed:#"online_indicator.png"]];
// Start syncing local records with the remote server
[[BTSyncEngine sharedEngine] startSync];
hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = #"Sync in progress";
}
}
#end
Related
I'm using a 2d game engine called Sprite kit within Xcode and i want to hide my ad banner in specific areas such as the game scene and then show it once it's game over for the player. But i'm having trouble trying to access the hidden property of the banner within other scenes/classes.
GameViewController.h
#import <UIKit/UIKit.h>
#import <SpriteKit/SpriteKit.h>
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <AVFoundation/AVFoundation.h>
#interface GameViewController : UIViewController
-(void) hideBanner;
#end
GameViewController.m
#implementation GameViewController
-(void) hideBanner {
self.bannerView.hidden = YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Create a banner ad and add it to the view hierarchy.
self.bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
//TEST UNIT ID
self.bannerView.adUnitID = #"ca-app-pub-3940256099942544/2934735716";
self.bannerView.rootViewController = self;
[self.view addSubview:self.bannerView];
GADRequest *request = [GADRequest request];
request.testDevices = #[ #"*log id*" ];
[self.bannerView loadRequest:request];
}
GameScene.h
#class GameViewController;
#interface GameScene : SKScene <SKPhysicsContactDelegate>
#property (strong, nonatomic) GameViewController *gameViewController;
#end
GameScene.m
//This line of code will be executed in the "performGameOver" method but it does not work and the banner is still shown?
[self.gameViewController hideBanner];
You should use NSNotification
In viewController.m
- (void)handleNotification:(NSNotification *)notification {
if ([notification.name isEqualToString:#"hideAd"]) {
[self hidesBanner];
}else if ([notification.name isEqualToString:#"showAd"]) {
[self showBanner];
}}
-(void)hidesBanner {
NSLog(#"HIDING BANNER");
[adView setAlpha:0];
self.bannerIsVisible = NO;
}
-(void)showsBanner {
NSLog(#"SHOWING BANNER");
[adView setAlpha:1];
self.bannerIsVisible = YES;
}
In your scene:
Sends message to viewcontroller to show ad.
[[NSNotificationCenter defaultCenter] postNotificationName:#"showAd" object:nil];
Sends message to viewcontroller to hide ad.
[[NSNotificationCenter defaultCenter] postNotificationName:#"hideAd" object:nil];
More info:
https://stackoverflow.com/a/21967530/4078517
I have a split view controller set up as a video player. The master view is a list of available videos and the detail view should play the selected video from the list.
I'm able to send the required properties to the detail view from the master (url, start time, end time...) but I'm only getting audio.
When a selection is made from the master view a delegate -(void)didselectVid: method gets fired in the detail view.
- (void)viewDidLoad
{
[super viewDidLoad];
if (selectedBool) {
timer = [NSTimer
scheduledTimerWithTimeInterval:1.0
target:self
selector:#selector(timedJob)
userInfo:nil
repeats:YES];
[timer fire];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
NSString * videoStr = [NSString stringWithFormat:#"%#/%#", gameVideoURL , videoUrlStr];
NSString * urlStrEscaped = [videoStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL * dataURL = [NSURL URLWithString:urlStrEscaped];
moviePlayerCrl.movieSourceType = MPMovieSourceTypeStreaming;
moviePlayerCrl = [[MPMoviePlayerController alloc] initWithContentURL:dataURL];
[self registerForMovieNotifications];
}
}
- (void)registerForMovieNotifications
{
//movie is ready to play notifications
if ([self.moviePlayerCrl respondsToSelector:#selector(loadState)])
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
[self.moviePlayerCrl prepareToPlay];
}
//movie has finished notification
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
}
- (void)moviePlayerLoadStateChanged:(NSNotification*)notification
{
NSLog(#"load state changed");
//unless state is unknown, start playback
if ([self.moviePlayerCrl loadState] != MPMovieLoadStateUnknown)
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
[self.moviePlayerCrl.view setFrame: CGRectMake(0,
[UIApplication sharedApplication].statusBarFrame.size.height
+ self.navigationController.navigationBar.frame.size.height
+ self.navigationController.toolbar.frame.size.height,
self.view.bounds.size.width,
self.view.bounds.size.height
- [UIApplication sharedApplication].statusBarFrame.size.height
- self.navigationController.navigationBar.frame.size.height
- self.navigationController.toolbar.frame.size.height
- self.tabBarController.tabBar.frame.size.height
)]; // x, y, width, height
[self.view addSubview:self.moviePlayerCrl.view];
[self.view bringSubviewToFront:self.moviePlayerCrl.view];
[self.moviePlayerCrl setFullscreen:NO animated:YES];
[self.moviePlayerCrl play];
[moviePlayerCrl setCurrentPlaybackTime:startPlaybackTime];
}
}
-(void)didselectVid:(VideoClipData *)vid
{
videoUrlStr = vid.evtUrlStr;
startTime = vid.evtStartStr;
endTime = vid.evtEndTimeStr;
gameNamesStr = vid.evtNameStr;
double startTimeInterval = [startTime doubleValue];
double endTimeInterval = [endTime doubleValue];
startPlaybackTime = startTimeInterval;
endPlaybackTime = endTimeInterval;
selectedBool = YES;
[self viewDidLoad];
}
The parent view frame and the MoviePlayerController view's frame have to be same before making MoviePlayerController.view a subview.
i.e Have one more view inside your master view say playerContainerView. Before adding the moviePlayerCrl.view as the subview of playerContainerView, set the playerContainerView and moviePlayerCrl.view to the same frame.
This should work.
I was able to fix this by calling didselectVid differently. With what I assume is proper split view delegation:
in master view .h :
#import "VideoClipData.h"
#protocol DetailDelegate <NSObject>
-(void)didselectEvtVid:(VideoClipData *) vid;
#end
#import <UIKit/UIKit.h>
#class DetailView;
#interface MasterView : UIViewController
#property (strong, nonatomic) DetailView *detailViewController;
#property (nonatomic, unsafe_unretained) id<DetailDelegate> delegate;
master view .m:
- (void)viewDidLoad {
[super viewDidLoad];
self.detailViewController = (DetailView *)[[self.splitViewController.viewControllers lastObject] topViewController];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.detailViewController didselectEvtVid:gameVideos];
}
And instead of calling viewDidLoad again I called [self configureView]; as given in apple's split view example.
In the Tasks sample app for the Dropbox Datastore API (found here) the observers are set up and discarded in viewWillAppear and viewWillDisappear, respectively:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
__weak TasksController *slf = self;
[self.accountManager addObserver:self block:^(DBAccount *account) {
[slf setupTasks];
}];
[self setupTasks];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.accountManager removeObserver:self];
if (_store) {
[_store removeObserver:self];
}
}
I am trying to set up global observers in a singleton class and am using init and dealloc since my class isn't a view controller.
//Custom init method to start up our Dropbox observer
- (id)init {
self = [super init];
if(!self) return nil;
[self startDatastore];
__weak typeof(self) weakSelf = self;
[self.store addObserver:self block:^{
[weakSelf getRemoteDropboxChanges];
}];
return self;
}
-(void)dealloc
{
//Stop listening for Dropbox changes
if(self.store) {
[self.store removeObserver:self];
}
}
...but alas, this doesn't work (the observer's block never fires). Can someone help me understand the difference?
I have a - (void)setViewControllers:(NSArray *)viewControllers direction:(UIPageViewControllerNavigationDirection)direction animated:(BOOL)animated completion:(void (^)(BOOL finished))completion set up in a method. Whenever the method is called it doesn't go to the next page. Instead, it goes to the UIPageViewController storyboard and then crashes. I'm not sure what I'm doing wrong. I am using MSPageViewController for the pageviewcontroller, could that be it?
Heres my code:
UIViewController *viewcont = [[UIViewController alloc]init];
NSArray *viewControllers = [NSArray arrayWithObject:viewcont];
[self setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
Thanks.
There are 3 storyboards all conforming to MSPageViewControllerChild with the pageIndex property synthesized. IntroPageViewController is the first storyboard (p1).
PagingViewController.h:
//
// PagingViewController.m
// MordechaiLevi
//
// Created by Mordechai Levi on 4/10/14.
// Copyright (c) 2014 Mordechai Levi. All rights reserved.
//
#import "PagingViewController.h"
#import "IntroPageViewController.h"
#import "MSPageViewController.h"
#interface PagingViewController ()
#end
#implementation PagingViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.device = [UIDevice currentDevice];
self.device.proximityMonitoringEnabled = YES;
if (self.device.proximityMonitoringEnabled == YES) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(sensorCovered) name:#"UIDeviceProximityStateDidChangeNotification" object:nil];
}else{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Uh Oh!" message:#"To use this app you need a device with a proximity sensor." delegate:self cancelButtonTitle:#"Got it" otherButtonTitles:nil, nil];
[alert show];
}
self.view.backgroundColor = [UIColor colorWithRed:0.2 green:0.859 blue:0.643 alpha:1.0];
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
- (void)sensorCovered {
if (self.device.proximityState == YES) {
IntroPageViewController *viewcont = [[IntroPageViewController alloc]init];
NSArray *viewControllers = [NSArray arrayWithObject:viewcont];
[self setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
NSLog(#"sensor covered");
}else{
NSLog(#"sensor not covered");
}
}
- (NSArray *)pageIdentifiers {
return #[#"p1", #"p2", #"p3"];
}
#end
Looks like you're using MSPageViewController, with a controller that doesn't conform to MSPageViewControllerChild.
From the documentation:
Each of them [controllers] must be a class that conforms to MSPageViewControllerChild (if you don't need to add any extra functionality to it you can use MSPageViewControllerPage).
My uitableview calls reloaddata when the orientation of the device changes (makes sense, since the number of cells displayed changes, is called in layout subviews as far as I could understand from the documentation), however this is problematic for me, because I am performing a download in the background and I don't want some of the files to suddenly appear. Is there a way to stop the default behaviour and let me reload manually when I want to?
EDIT:
I will try to explain better. on the top of my tableview, I have a button called "sync" which starts a syncing request from the server, this sync request first get a JSON object, which holds the information I would like to display in the tableview, but each of the uitableview items represents a file I'm downloading from the internet.
While the files are downloading I have an activity indicator on screen, only when the files finish downloading I want to reload the table. The problem is, the UITableview automatically calls reloaddata when the user changes orientation, so the cells fill with the information from the json before the downloaded files finished downloading.
code:
#implementation BIDManageFilesViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(newDataFinishedDownloading) name:kBIDContentManagerContentDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(newDataStartedDownloading:) name:kBIDContentManagerStartedDownloadingContent object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(contentAlreadyUpToDate) name:kBIDContentUpToDate object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(contentStartingSync) name:kBIDContentStartingSync object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(contentEndingSync) name:kBIDContentEndingSync object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(singleDownloadFinished) name:kBIDFinishedDownloadingSingleContent object:nil];
self.navigationController.navigationBarHidden = NO;
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:#"Sync"
style:UIBarButtonItemStyleDone target:self action:#selector(Sync)];
self.navigationItem.leftBarButtonItem = leftButton;
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:#"Display Mode"
style:UIBarButtonItemStyleDone target:self action:#selector(dismissSelf)];
self.navigationItem.rightBarButtonItem = rightButton;
self.navigationItem.title = #"Content Manager";
self.navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectZero];
[self.view addSubview:_navigationBar];
[self.navigationBar pushNavigationItem:self.navigationItem animated:NO];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
}
-(void)layoutNavigationBar{
if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown)
{
self.navigationBar.frame = CGRectMake(0, self.tableView.contentOffset.y, self.view.frame.size.width, self.topLayoutGuide.length + 44);
}
else
{
self.navigationBar.frame = CGRectMake(0, self.tableView.contentOffset.y, self.view.frame.size.height, self.topLayoutGuide.length + 44);
}
NSLog(#"width: %f", self.view.frame.size.width);
NSLog(#"height: %f", self.view.frame.size.height);
self.tableView.contentInset = UIEdgeInsetsMake(self.navigationBar.frame.size.height, 0, 0, 0);
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
//no need to call super
[self layoutNavigationBar];
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self layoutNavigationBar];
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
-(void)viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
[self layoutNavigationBar];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a story board-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
-(void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
self.navigationController.navigationBarHidden = YES;
}
-(void)newDataStartedDownloading: (NSNotification *)notif
{
self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
_hud.labelText = #"Downloading...";
_hud.detailsLabelText = [NSString stringWithFormat:#"1/%#",[notif.userInfo objectForKey:#"downloadFileNumber"]];
}
-(void)singleDownloadFinished
{
NSString *currentText = _hud.detailsLabelText;
NSArray *subStrings = [currentText componentsSeparatedByString:#"/"];
NSInteger downloadsPlusOne = [[subStrings objectAtIndex:0] integerValue]+1;
NSString *newTextForLabel = [NSString stringWithFormat:#"%d/%#", downloadsPlusOne, [subStrings objectAtIndex:1]];
_hud.detailsLabelText = newTextForLabel;
}
-(void)newDataFinishedDownloading
{
_thereIsNewInfo = TRUE;
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self.tableView reloadData];
[[NSNotificationCenter defaultCenter] postNotificationName:kBIDnewDownloadedContentReadyToBeDispayedNotification object:nil userInfo:nil];
}
-(void)contentAlreadyUpToDate
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Sync Alert"
message:#"Files Are Already Up To Date"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles: nil];
[alert show];
}
-(void)contentStartingSync
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = #"Syncing...";
}
-(void)contentEndingSync
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
-(void)Sync
{
[AppDelegate.appContentManager downloadContent];
}
-(void)dismissSelf
{
if (![AppDelegate.appContentManager subsetArrayFromFileArrayWithNonVidContentThatShouldDisplay] && ![AppDelegate.appContentManager subsetArrayFromFileArrayWithVideoContentThatShouldDisplay]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"No Files to Display"
message:#"Please update or enable content"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles: nil];
[alert show];
return;
}
else if ([AppDelegate.appContentManager subsetArrayFromFileArrayWithNonVidContentThatShouldDisplay])
{
[self dismissViewControllerAnimated:YES completion:Nil];
}
else
{
[self performSegueWithIdentifier:#"goToVideos" sender:self];
}
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:#"goToVideos"])
{
((BIDViewController *)segue.destinationViewController).stackedByManager = TRUE;
}
}
#end
It's not necessary to reloaddata on orientation change but if you want to reload table try to call [myTable reloadData] after the completion of the background download and only if the orientation has changed (you can set a bool for this on orient. change).