Combining a TabBar and Navigation Controller IOS8 - uinavigationcontroller

I'm new to iOS and I have troubles to display a navigation controller in my taBbar after Xcode 6 update.
With Xcode 5, it was working perfectly but now on the simulator I get an error message "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'" and the app crashes.
Here is my code:
**appDelegate.m**
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor =[UIColor whiteColor];
[self.window makeKeyAndVisible];
*// tabBar items*
ItemUnViewController *itemUnViewController = [[ItemUnViewController alloc]
initWithNibName:nil
bundle:NULL];
ItemDeuxViewController *itemDeuxViewController = [[ItemDeuxViewController alloc]
initWithNibName:nil
bundle:NULL];
*//tabBar*
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:#[itemUnViewController,itemDeuxViewController]];
*//setting tabBar as rootView*
self.window.rootViewController = tabBarController;
*// navigation Controllers*
UINavigationController *itemUnNavigationController =
[[UINavigationController alloc]
initWithRootViewController:itemUnViewController];
UINavigationController *itemDeuxNavigationController =
[[UINavigationController alloc]
initWithRootViewController:itemDeuxViewController];
*//Combining tabBar and Navigation Controllers*
[tabBarController setViewControllers:#
[itemUnNavigationController,itemDeuxNavigationController]];
return YES;
}
I even tried this way http://blog.rifkilabs.net/exploring-navigation-controller-and-tab-bar-controller.html but i get the same error message.
Thanks for your help.

tabBar_Controller = [[UITabBarController alloc]init];
[tabBar_Controller setDelegate:self];
ViewController1 *obj_1 = [obj_story instantiateViewControllerWithIdentifier:#"VC1"];
UINavigationController *navi_vc1 = [[UINavigationController alloc]initWithRootViewController:obj_1];
navi_vc1.navigationBarHidden = YES;
ViewController2 *obj_2 = [obj_story instantiateViewControllerWithIdentifier:#"VC2"];
UINavigationController *navi_vc2 = [[UINavigationController alloc]initWithRootViewController:obj_2];
navi_vc2.navigationBarHidden = YES;
[tabBar_Controller setViewControllers:[NSArray arrayWithObjects:navi_vc1,navi_vc2,nil]];
//Hide Tabbar View Controller.//
[self hideTabBar]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(void) hideTabBar
{
for(UIView *view in tabBar_Controller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, [UIScreen mainScreen].bounds.size.height, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, [UIScreen mainScreen].bounds.size.height)];
}
}
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(void)create_BottomBarButton
{
UIView *viewBottom = (UIView *)[self.window viewWithTag:Tag_BottomView];
if (viewBottom == nil)
{
#try
{
viewBottom = [[UIView alloc]init];
[viewBottom setFrame:CGRectMake([UIScreen mainScreen].bounds.origin.x, [UIScreen mainScreen].bounds.size.height-(HeightOfBottomBar+KsubviewHeight), [UIScreen mainScreen].bounds.size.width, HeightOfBottomBar)];
[viewBottom setBackgroundColor:RGB(47.0, 45.0, 45.0, 1.0)];
[viewBottom setTag:Tag_BottomView];
NSArray *arrImage = [NSLocalizedString(#"arrBottomBarImgs", nil)componentsSeparatedByString:#","];
float x = 0.0;
for (int i =0; i < kTotalTab; i++) {
[self create_TabBtn:viewBottom frame:CGRectMake(x, 0, 62,62) withTag:i+1 withImage:[arrImage objectAtIndex:i]];
x += 64.5;
}
[self.window addSubview:viewBottom];
}
#catch (NSException *exception)
{
NSLog(#"EXCEPTON %#",[exception description]);
}
}
}
-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-
-(void)select_Tab:(UIButton *)btn
{
#try {
[[tabBar_Controller.viewControllers objectAtIndex:btn.tag-1] popToRootViewControllerAnimated:YES];
[tabBar_Controller setSelectedIndex:btn.tag-1];
}
#catch (NSException *exception) {
NSLog(#"%s",__PRETTY_FUNCTION__);
}
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(void)pushTabBarIntoNavigationBar
{
[navi setNavigationBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[navi pushViewController:tabBar_Controller animated:YES];
}
-=-=-=-=-=-=-=-=-=-=-=
navi = [[UINavigationController alloc]initWithRootViewController:tabBar_Controller];
[navi setNavigationBarHidden:YES];
self.window.rootViewController = navi;

Related

Method cellForRowAtIndexPath method was not get called

Am a beginner in iOS, am creating an application with the help of table view. I just run my application, while running the app, the app does not calling the method cellForRowIndexPath. Am using Json as web service. In the output screen, the parsing data is shown but it is not get display in simulator. i put breakpoint and i understood the cellForRowIndexPath path was not called. I drag datasourse and data delegate to files onner of xib file. but nothing is occurring... the table view is get displaying but there is no content... am screwed.. Any one please help me...
#implementation MSPackagesController
#synthesize packageTable;
#synthesize packages;
#synthesize mainCtrl;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void)viewDidLoad
{
[super viewDidLoad];
}
-(void)parseData {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.animationType = MBProgressHUDAnimationFade;
hud.detailsLabelText = #"Loading...";
MSJsonParser *parser = [[MSJsonParser alloc]initWithParserType:kPackagesParsing];
parser._parserSource = self;
[parser requestParsingWithUrl:PACKAGES_LIST_URL];
}
-(void)sharePackageFromCell:(UIButton*)btn
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.animationType = MBProgressHUDAnimationFade;
hud.detailsLabelText = #"Loading...";
NSString *title = [[self.packages objectAtIndex:btn.tag] packageName];
/*NSURL *imgUrl = [NSURL URLWithString:[[self.promotions objectAtIndex:btn.tag] picture]];
NSData *imgdata = [NSData dataWithContentsOfURL:imgUrl];
UIImage *image = [UIImage imageWithData:imgdata];*/
// NSURL *imgUrl = [NSURL URLWithString:[[self.packages objectAtIndex:btn.tag] picture]];
NSString *desc = [[self.packages objectAtIndex:btn.tag] packageDescription];
NSString *message = #"Visit GlamZapp in AppStore";
UIActivityViewController *activityCtrl = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:title,desc,message, nil] applicationActivities:nil];
activityCtrl.excludedActivityTypes = #[UIActivityTypePrint,UIActivityTypePostToWeibo,UIActivityTypeMessage,UIActivityTypeAssignToContact];
activityCtrl.completionHandler = ^(NSString *activityType, BOOL completed)
{
NSLog(#" activityType: %#", activityType);
NSLog(#" completed: %i", completed);
};
[self.mainCtrl presentViewController:activityCtrl animated:YES completion:^{
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [packages count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
MSPackagesCell *cell = (MSPackagesCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *cells = [[NSBundle mainBundle]loadNibNamed:[Common checkDeviceforController:#"MSPackagesCell"] owner:nil options:nil];
for (id eachObject in cells) {
cell = eachObject;
break;
}
//cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
// Configure the cell...
// NSURL *imgUrl = [NSURL URLWithString:[[self.promotions objectAtIndex:indexPath.row]picture]];
//[cell.promoImg setImageWithURL:imgUrl placeholderImage:[UIImage imageNamed:#"slider_dummy.jpg"] andSize:cell.promoImg.frame.size];
cell.PackageName.text = [[self.packages objectAtIndex:indexPath.row] packageName];
cell.PackageDescription.text = [[self.packages objectAtIndex:indexPath.row] packageDescription];
// NSMutableAttributedString *strikedPrice = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:#"%# %#",CURRENCY_UNIT,[[self.packages objectAtIndex:indexPath.row] packageAmount] ] ];
// [strikedPrice addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInt:2] range:NSMakeRange(0, [strikedPrice length])];
//cell.oldPriceLabel.attributedText = strikedPrice;
cell.PriceLabel.text = [NSString stringWithFormat:#"%# %#",CURRENCY_UNIT,[[self.packages objectAtIndex:indexPath.row] packageAmount] ];
//[string appendFormat:#"%#\r\n", message];
// cell.promocodelabel.text = [NSString stringWithFormat:#"Promo code: %#",[[self.packages objectAtIndex:indexPath.row] promoCode]];
cell.ShareButton.tag = indexPath.row;
[cell.ShareButton addTarget:self action:#selector(sharePackageFromCell:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// MSPackageDetailsController *promDet = [[MSPackageDetailsController alloc]initWithNibName:[Common checkDeviceforController:#"MSPackageDetailsController"] bundle:nil];
// promDet.delegate = self;
// promDet.offerId = [[self.packages objectAtIndex:indexPath.row] promoId];
// promDet.title = [[self.packages objectAtIndex:indexPath.row] promoTitle];
// [self.delegate didSelectPromotion:promDet];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
-(void)foundPackagesData:(NSArray *)packa
{
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
self.packages = packa;
[self.packageTable reloadData];
}
-(void)connectionFailed
{
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}
I think you have not added UITableviewDataSource and UITableViewDelegate in your .h file
Add UITableViewDataSource,UITableViewDelegate in interface (.h) file
#interface MSPackagesController : UIViewController <UITableViewDataSource,UITableViewDelegate>

SQlite Database ios UITableView

I Have Change the Whole Database...
Now I Have Two Tables that Display Below
First Table:- Category Table
Cat_id CategoryName
====================================
1 Jesus
2 Buddha
3 BillGates
Second Table :- SayingTable
Say_id Cat_id Sayings
===================================
1 1 Never Say False
2 1 God Bless you
3 1 Be a Good Boy
4 2 Make a Peaceful World
5 2 Never Lie with the People
and I Have Used UITableView in My Firstview Controller
That Display Like Below Image
When i Click on Jesus Christ Cell..Or any Other cell then it Crash..
My Code is Below
FirstViewController.m
- (void)viewDidLoad
{
dataaray = [[NSMutableArray alloc] init];;
[dataaray addObject:#"Jesus Christ"];
[dataaray addObject:#"Budhdha"];
[dataaray addObject:#"BillGates"];
jesus = [[NSMutableArray alloc] init];
Buddha = [DatabaseOperation SelectCategory:2];
Buddha = [Buddha valueForKey:#"Saying"];
NSLog(#"Buddha Bhagwan Category=%#",Buddha);
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.dataaray count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier = #"Cellidentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell==nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.textLabel.text = [dataaray objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *mydetail = [[DetailViewController alloc] initWithNibName:#"DetailViewController" bundle:nil];
if ([[dataaray objectAtIndex:indexPath.row] isEqual:#"Jesus Christ"])
{
mydetail.flag=1;
int SelectedRow = (indexpath.row+1);
jesus = [DatabaseOperation SelectCategory:SelectedRow];
jesus = [jesus valueForKey:#"Saying"];
NSLog(#"Jesus Category===%#",jesus);
mydetail.Jesus2Array = [jesus mutablecopy]; //Note Jesus2 is an Array of detailviewcontroller
}
else if ([[dataaray objectAtIndex:indexPath.row] isEqualToString:#"Budhdha"])
{
mydetail.flag=2;
SelectedRow = (indexpath.row+1);
Buddha = [DatabaseOperation SelectCategory:SelectedRow];
jesus = [jesus valueForKey:#"Saying"];
NSLog(#"Jesus Category===%#",jesus);
mydetail.Buddha2Array = [Buddha mutableCopy]; //Note Jesus2 is an Array of detailviewcontroller
}
DetailviewController.m
- (void)viewDidLoad
{
NSLog(#"Flag Value===%d",flag);
NSLog(#"Jesus 2 Array===%#",Jesus2Array);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (flag==1)
{
return [Jesus2Array count];
}
if(flag==2)
{
return [Buddha2array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if (flag==1)
{
cell.textLabel.text = [Jesus2Array objectAtIndex:indexPath.row];
}
DatabaseOperation.h
#import <Foundation/Foundation.h>
#import "DatabaseOperation.h"
#import <sqlite3.h>
#interface DatabaseOperation : NSObject
{
}
+(void)Check_Create_Database;
+(NSMutableArray*)SelectCategory:(int)Category_id;
DatabaseOperation.m
#import "DatabaseOperation.h"
#import <sqlite3.h>
static NSString *dbPath;
static NSString *databaseName=#"Message.sqlite";
#implementation DatabaseOperation
+(void)Check_Create_Database
{
dbPath =[[NSHomeDirectory() stringByAppendingPathComponent:#"Documents"] stringByAppendingPathComponent:databaseName];
BOOL success;
NSFileManager *fm=[NSFileManager defaultManager];
success=[fm fileExistsAtPath:dbPath];
if(success){
return;
}
NSString *dbPathFromApp=[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName];
NSLog(#"dbPathFromApp = %#",dbPathFromApp);
[fm copyItemAtPath:dbPathFromApp toPath:dbPath error:nil];
}
+(NSMutableArray*)SelectCategory:(int)Category_id
//+(NSMutableArray*)SelectedCategory
{
sqlite3 *database;
NSMutableArray *dic=[[NSMutableArray alloc] init];
NSString *SAYING;
if(sqlite3_open([dbPath UTF8String] , &database) == SQLITE_OK)
{
NSString *sqlTmp=[NSString stringWithFormat:#"Select * from SayingTable Where Cat_id=%d",Category_id];
const char *sqlStmt=[sqlTmp UTF8String];
sqlite3_stmt *cmp_sqlStmt;
if(sqlite3_prepare_v2(database, sqlStmt, -1, &cmp_sqlStmt, NULL)==SQLITE_OK)
{
while(sqlite3_step(cmp_sqlStmt)==SQLITE_ROW)
{
NSLog(#"SQL Statements====%s",sqlStmt);
SAYING=[NSString stringWithUTF8String:(char *) sqlite3_column_text(cmp_sqlStmt, 2)];
NSMutableDictionary *dicObj=[[NSMutableDictionary alloc] init];
[dicObj setValue:[NSString stringWithFormat:#"%#",SAYING] forKey:#"Saying"];
[dic addObject: dicObj];
}
}
sqlite3_finalize(cmp_sqlStmt);
}
sqlite3_close(database);
When I Click the Cell then Detailview Controller is Not Loading.....i don't know whats Wrong in my Code Please Help..
Thank You...

Warning: Attempt to present UINavigationController on SampleViewController: whose view is not in the window hierarchy

i have try all the solution in this forum but still cannot solve. Can anybody help me out with these problem? i want the app to open the inboxData class that contain a tableView when the NSUserDefault read the key #"url" from Urban Airship..
this is from SampleViewController class;
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *action_9 = [defaults objectForKey:#"url"];
if ([[[NSUserDefaults standardUserDefaults]objectForKey:#"url"] isEqualToString:#"aa9"])
{
inboxData *screen=[[inboxData alloc]initWithNibName:#"inboxData" bundle:nil];
screen.strGetTableSelect=#"1";
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:screen];
[self presentModalViewController:navigationController animated:YES];
}
}
it return with these error..
Warning: Attempt to present UINavigationController on SampleViewController whose view is not in the window hierarchy
Your SampleViewController not in the Window hierarchy, You need to set in window.
In your appDelegate, do like this,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[SampleViewController alloc] initWithNibName:#"SampleViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
If you are using storyboad, Use like this in didFinishLaunchingWithOptions method,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"MainStoryboard_iPhone"
                                                             bundle: nil];
 
    SampleViewController *mainViewController = (SampleViewController*)[mainStoryboard
                                                       instantiateViewControllerWithIdentifier: #"SampleViewController"];
 
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window setRootViewController:navigationController];
    [self.window setBackgroundColor:[UIColor whiteColor]];
    [self.window makeKeyAndVisible];
 
    return YES;
}
In your view controller,
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *action_9 = [defaults objectForKey:#"url"];
if ([[[NSUserDefaults standardUserDefaults]objectForKey:#"url"] isEqualToString:#"aa9"])
{
inboxData *screen=[[inboxData alloc]initWithNibName:#"inboxData" bundle:nil];
screen.strGetTableSelect=#"1";
[self presentModalViewController:screen animated:YES];
}
}

GPUImageView Integration in my project

What I am trying to do is this.
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url2 = [[NSBundle mainBundle] URLForResource:#"NAN" withExtension:#"mov"];
GPUImageMovie *movie2 = [[GPUImageMovie alloc] initWithURL:url2];
movie2.playAtActualSpeed = YES;
filter0 = [[GPUImageSepiaFilter alloc] init];
[movie2 addTarget:filter0];
[filter0 addTarget:view0]; // view0 is a GPUImageView taken in nib
[self recordVideo];
isRecording = YES;
[movie2 startProcessing];
[movieWriter setCompletionBlock:^{
if (isRecording) {
[self stopRecording];
isRecording = NO;
} }];
}
-(void)recordVideo {
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:#"file.mov"];
NSURL *url = [NSURL fileURLWithPath:path];
NSFileManager *fm = [NSFileManager defaultManager];
[fm removeItemAtPath:path error:nil];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:url size:CGSizeMake(640, 480)];
[filter0 addTarget:movieWriter];
[movieWriter startRecording];
}
-(void)stopRecording {
[movieWriter finishRecording];
}
But this is not working at all. I always get a black video with this code. There is no crash, I get a black video with the same duration as of original video. Has anyone faced the same issue. Kindly help.
Any help would be great.

ZUUIRevealController - Memory allocations keeps on increasing & slow UIAlertView & UIActionsheet

I am starting with new iOS app in which I have to use Reveal control. So I planned to use great ZUUIRevealController library. I just created UI for 2 - 3 screens . In one of those screen I have to shown UIAlertView & UIActionsheet. But I realised that UIAlertView & UIActionsheet shows very slowly (it adds black overlay first & then shows UIAlertView/UIActionsheet, kind of alert view hangs while showing. Animation is not smooth). I didn't added any logic for coding just created the UI. I didn't use any background thread / dispatch_asyn(). So there is no issue of updating UI from background thread. So I checked the memory leaks & allocations. I didn't see any memory leaks , but memory allocations keeps on increasing while I reveal the menu & push new view controller. It doesn't decrese when I pop the view controller. Here are the screenshots :
1) When app launches
2) After some time , when I push new view controller, pop view controller
I know ZUUIRevealController library creates new instance of view controller every time I select a row from Menu. So I crated the instance variables of view controllers in .h file , but still I have same problem.
Here is my code
// AppDelegate.m
// On SplashViewController , I decide whether to show menu or Login screen
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.splashViewController = [[SplashViewController alloc]initWithNibName:#"SplashViewController" bundle:nil];
self.window.rootViewController = self.splashViewController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[self customizeUIControlsAppearance];
return YES;
}
// SplashViewController.m
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
BOOL isLoggedIn = YES;
if(isLoggedIn){
[self showMenuViewController];
}
else{
[self showStartUpViewController];
}
}
-(void)showStartUpViewController
{
StartUpViewController *startUpViewController = [[StartUpViewController alloc]initWithNibName:#"StartUpViewController" bundle:nil];
UINavigationController *navController=[[UINavigationController alloc] initWithRootViewController:startUpViewController];
[self presentViewController:navController animated:NO completion:^{
}];
}
-(void)showMenuViewController
{
MenuViewController *menuViewController=[[MenuViewController alloc] init];
CategoryViewController *categoryViewController=[[CategoryViewController alloc]initWithNibName:#"CategoryViewController" bundle:nil];
categoryViewController.isViewControllerShownFromMenu = YES;
UINavigationController *navController=[[UINavigationController alloc] initWithRootViewController:categoryViewController];
RevealController *revealController=[[RevealController alloc] initWithFrontViewController:navController rearViewController:menuViewController];
[self presentViewController:revealController animated:NO completion:^{
}];
}
// MenuViewController.m
// SettingsViewController & NewsViewController are decalred in .h file with property & syntheszie
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
RevealController *revealController = [self.parentViewController isKindOfClass:[RevealController class]] ? (RevealController *)self.parentViewController : nil;
// Switch using Section Number
switch (indexPath.section) {
case OTHER_SECTION:
switch (indexPath.row) {
case NEWS:
[self showNewsViewControllerUsingRevealController:revealController];
break;
case SETTINGS:
[self showSettingsViewControllerUsingRevealController:revealController];
break;
default:
break;
}
break;
default:
break;
}
}
#pragma mark - Show News & Settings View Controllers
-(void)showNewsViewControllerUsingRevealController:(RevealController*)revealController
{
if ([revealController.frontViewController isKindOfClass:[UINavigationController class]] && ![((UINavigationController *)revealController.frontViewController).topViewController isKindOfClass:[NewsViewController class]])
{
if(!self.newsViewController)
self.newsViewController = [[NewsViewController alloc] initWithNibName:#"NewsViewController" bundle:nil];
self.newsViewController.isViewControllerShownFromMenu = YES;
UINavigationController *navigationController= [[UINavigationController alloc] initWithRootViewController:self.newsViewController];
[revealController setFrontViewController:navigationController animated:NO];
}
else
{
[revealController revealToggle:self];
}
}
-(void)showSettingsViewControllerUsingRevealController:(RevealController*)revealController
{
if ([revealController.frontViewController isKindOfClass:[UINavigationController class]] && ![((UINavigationController *)revealController.frontViewController).topViewController isKindOfClass:[SettingsViewController class]])
{
if(!self.settingsViewController)
self.settingsViewController= [[SettingsViewController alloc] initWithNibName:#"SettingsViewController" bundle:nil];
self.settingsViewController.isViewControllerShownFromMenu = YES;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.settingsViewController];
[revealController setFrontViewController:navigationController animated:NO];
}
else
{
[revealController revealToggle:self];
}
}
// Code for shwoing UIAlertView & UIActionsheet
-(void)showAlertWithTitle:(NSString*)title andMessage:(NSString*)message
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
}
-(void)btnInviteTapped:(id)sender event:(UIEvent*)event
{
UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:NSLocalizedString(#"FRIENDS_VC:INVIT_ACTIONSHEET_TITLE", nil) delegate:self cancelButtonTitle:NSLocalizedString(#"FRIENDS_VC:ACTIONSHEET_CANCEL_BUTTON",nil) destructiveButtonTitle:nil otherButtonTitles:NSLocalizedString(#"FRIENDS_VC:ACTIONSHEET_SMS_BUTTON",nil),NSLocalizedString(#"FRIENDS_VC:ACTIONSHEET_EMAIL_BUTTON",nil), nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[actionSheet showInView:self.view];
}
By the way I have 11 menu items.
My Login & Regsiter flow is not embedded in MenuViewController. On Login & REgsiter , UIAlertView & UIActionSheet shows smoothly.
Any idea whats going wrong here ? Did I make some mistake in coding ?
Why my UIAlertView & UIActionsheet are not showing smoothly ?
Any kind of help is appreciated. Thanks.

Resources