i use the JTRevealSidebarV2 and have a problem. The sidebar is not always visible. It is sometimes white. Have anybody a solution?
This is the Code for see and dismiss the sidebar:
// This is an examle to configure your sidebar view through a custom UIViewController
- (UIView *)viewForLeftSidebar {
[self changeAllButtonImageUnpressed];
// Use applicationViewFrame to get the correctly calculated view's frame
// for use as a reference to our sidebar's view
CGRect viewFrame = self.navigationController.applicationViewFrame;
UITableViewController *controller = self.leftSidebarViewController; NSLog(#"Controller.view %#", controller.view);
if ( controller == nil ) {
self.leftSidebarViewController = [[SidebarViewController alloc] init];
self.leftSidebarViewController.sidebarDelegate = self;
controller = self.leftSidebarViewController;
//controller.title = #"LeftSidebarViewController";
}
controller.view.frame = CGRectMake(0, viewFrame.origin.y, 250, viewFrame.size.height);
controller.view.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
return controller.view;
}
This happens when you open a sidebar than hit the home key. reopen the app and its all messed up
Related
In my app I have this hierarchy:
AppViewController (root)-->HUDViewController (as a container viewcontroller within AVC)-->NavBar (subview of UIView)-->UIButtons
When you touch some of the buttons they need to launch a UIPopoverController from AVC. I send a notification back from the NavBar class to AVC. In the selector for the notification center I have this code
...
//get the client list from the notification
[dictPopoverData setObject: [[notification userInfo] objectForKey:#"Client List"] forKey:#"Client List"];
//get the frame of the object launching the popover
popupCallerFrame = CGRectFromString([[notification userInfo] objectForKey:#"Caller Frame"]);
[self presentPopOver:CLIENT_LIST:YES:dictPopoverData];
...
then in presentPopOver I have this:
- (void) presentPopOver : (int) popoverID : (BOOL) isTable : (NSMutableDictionary*) dictPopoverData {
if (self.myPopoverController != nil) {
[self.myPopoverController dismissPopoverAnimated:YES];
self.myPopoverController = nil;
}
CGRect launchFrame;
//init the popover
if (popoverID == CLIENT_LIST) {
ClientListPopover* vcClientList = [[ClientListPopover alloc] initWithStyle:UITableViewStylePlain];
vcClientList.arrDataSource = [dictPopoverData objectForKey:#"Client List"];
self.myPopoverViewController = vcClientList;
//set the launch frame
launchFrame = popupCallerFrame;
launchFrame.origin.x = launchFrame.origin.x;
launchFrame.origin.y = launchFrame.origin.y + 100.0;
} else if (popoverID == PA_LIST) {
PAListPopover* vcPAList = [[PAListPopover alloc] initWithStyle:UITableViewStylePlain];
vcPAList.strClientNumber = [dictPopoverData objectForKey:#"Client Number"];
self.myPopoverViewController = vcPAList;
//set the launch frame
launchFrame = popupCallerFrame;
launchFrame.origin.x = launchFrame.origin.x;
launchFrame.origin.y = launchFrame.origin.y + 100.0;
}
//init and display the popover controller
if (self.myPopoverController == nil) {
//add the self.myPopoverViewController
self.myPopoverController = [[UIPopoverController alloc] initWithContentViewController:self.myPopoverViewController];
//display the popover
[self.myPopoverController presentPopoverFromRect:launchFrame inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
[self.myPopoverController setDelegate:self];
} else {
[self.myPopoverController dismissPopoverAnimated:YES];
self.myPopoverController = nil;
}
}
So what is suppose to happen is the user clicks the client button, notification gets sent to AVC, a UITable in a popover controller is presented. The user then selects a client from the table. Again, a notification is sent to AVC, the displayed client list popover should now be dismissed and the PA list popover should show. It seems that [self.myPopoverController dismissPopoverAnimated:YES] is not being called. I've traced it and it hits that line of code but nothing happens, the first popover remains on the screen. Any ideas of what I am doing wrong?
Edit: I forgot to mention I can't seem to assign a delegate to self.myPopoverController. Which is probably why the dismiss method is not firing.
Edit: I added the call to the delegate after the popover controller is inited. That didn't seem to make a difference. If I touch outside the first popover, without touching inside, it does dismiss and I can trace the method.
I started writing a project without really using the storyboard (as i was following a tutorial about creating an options menu for a game).
So i am trying to retroactively implement a way of moving between 2 UIViewControllers (MainGame and MatchScreen) that each has a UIView (MainMenu and VSComputer respectively).
Now in the MainMenu UIView I have created 4 buttons, with all their positions and settings, two of which are subviews - options and stats - that so appear and disappear when clicked on the current ViewController.
Now, the problem is, I need to somehow move from the main menu to the match screen using one of the other buttons named 'matchScreen'. I feel there must be something that i'm missing as no answer found in my research has worked for me yet.
I have embedded my main UIViewController with a navController (as suggested in other questions that i've seen) and then added a push segue to the 2nd ViewController. But i don't know how to make this apparent to my code. My code recognises nothing that i do in the storyboard it seems.
#interface JDTHMainMenu(){
JDTHOptionsScreen *theOptionScreen;
JDTHPlayerStats *thePlayerStatsScreen;
UIButton *optionScreenButton;
UIButton *matchScreenButton;
UIButton *deckScreenButton;
UIButton *statsScreenButton;
bool isPhone;
bool isOptionScreenOpen;
bool isPlayerStatsScreenOpen;
bool matchScreenButtonPressed;
UIView *tint;
int screenWidth;
int screenHeight;
AppData *appData;
}
So to be clear, JDTHMainMenu is a UIView in the JDTHViewController - the original, JDTHMatchScreen is the second ViewController and there is a UIView called JDTHVersusScreen. Im trying to go from one to the other. Also the JDTHAppDelegate only has return YES in the didFinishLaunching method. I feel i'm getting closer....but perhaps not...
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
appData = [AppData sharedData];
NSLog(#"Main Menu has loaded");
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
isPhone = YES;
} else {
isPhone = NO;
}
screenWidth = self.frame.size.width;
screenHeight = self.frame.size.height;
isOptionScreenOpen = NO;
isPlayerStatsScreenOpen = NO;
matchScreenButtonPressed = NO;
[self showOptionScreenButton];
[self showPlayerStatsScreenButton];
[self matchViewControllerButton:matchScreenButton];
[self deckViewerControllerButton:deckScreenButton];
}
return self;
}
-(IBAction)matchViewControllerButton:(UIButton *)sender{
CGRect rect;
UIFont *theFont;
if (isPhone == YES) {
rect = CGRectMake(38, 150, 134, 116);
theFont = [UIFont fontWithName:#"Zapfino" size:22];
} else {
rect = CGRectMake(275, 600, 200, 150);
theFont = [UIFont fontWithName:#"Zapfino" size:28];
}
matchScreenButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[matchScreenButton addTarget:self action:#selector(goToMatchView:sender:) forControlEvents:UIControlEventTouchDown];
[matchScreenButton.titleLabel setFont:theFont];
[matchScreenButton setTitle:#"VS Comp" forState:UIControlStateNormal];
matchScreenButton.frame = rect;
[matchScreenButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[matchScreenButton setBackgroundImage:[UIImage imageNamed:#"MainMenuOptionButton"] forState:UIControlStateNormal];
[self addSubview:matchScreenButton];
}
-(void)goToMatchView:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:#"pushToMatchView"]) {
JDTHMatchScreen *vc2 = (JDTHMatchScreen *)segue.destinationViewController;
vc2.name = self.textField.text;
}
}
A storyboard app has an entry in the info.plist file that tells the app that it's a storyboard app, and what the name of the storyboard is ("Main storyboard file base name" is the name of the key, and the value is the file name, without extension, of your storyboard). You would need to add this to your project to get it to recognize the storyboard. Also, non-storyboard apps usually have code in the app delegate to set up the initial controllers. This should be deleted for a storyboard app (the only code in the default template in didFinishLaunchingWithOptions: is "return YES"). It might be easier to just start a new storyboard based single view project and copy your files to it.
I am trying PSDFKit demo version to display pdf files in my application. I have added PSPDFViewcontroller as child view to app view hierarchy.And PSPDKIt toolbars are hidden.App is using toolbars of parent view controller.
My problem is that when I tried to add note annotation then it gets overlapped with bottom toolbar.
Could not find reason behind this strange behaviour.
What could be reason?
Here is my code
-(void)showDocumentWithFileURL:(NSURL *)url
{
NSData*pdfdata = [NSData dataWithContentsOfURL:url];
PSPDFDocument *document = [PSPDFDocument documentWithData:pdfdata];
[document.outlineParser outline]; //Parse outline..
self.psPdfViewController = [[PSPDFViewController alloc] initWithDocument:document];
self.psPdfViewController.scrollingEnabled = YES;
self.psPdfViewController.toolbarEnabled = NO;
self.psPdfViewController.delegate = self;
self.psPdfViewController.document.delegate = self;
self.psPdfViewController.shouldHideStatusBarWithHUD = NO;
self.psPdfViewController.renderAnimationEnabled = NO;
self.psPdfViewController.hidesBottomBarWhenPushed =YES;
//Hide bottom page scrollbar.
self.psPdfViewController.scrollDirection = PSPDFScrollDirectionVertical;
self.psPdfViewController.leftBarButtonItems = #[];
//Add pspdf view as chaild view controller.
[self addChildViewController:self.psPdfViewController];
[self.view addSubview:self.psPdfViewController.view];
//Add Navigation Bar and toolbar Buttons.
[self updateHeaderFooter];
}
else
{
[self updateHeaderFooter];
}
}
I want to check if my view has already been added to the view, so that the user cannot repeatedly add the new UIViewController onto the view.
if (!self.fmovc)
{
self.fmovc = [[FMOVC alloc] initWithNibName: #"FMOVC" bundle:nil];
}
BOOL viewAlreadyDisplayed = NO;
for (UIView * b in self.view.subviews)
{
if ([b isKindOfClass:[FMOVC class]])
{
viewAlreadyDisplayed = YES;
}
}
if (!viewAlreadyDisplayed)
{
[self.view addSubview:self.fmovc.view];
}
This is not working because it never triggers
viewAlreadyDisplayed = YES;
What is the correct way to go about finding if your view is already being displayed?
Thanks,
-Code
Before adding just removeItFromSuperView...It may solve your prob
[self.fmovc.view removeFromSuperview];
[self.view addSubview:self.fmovc.view];
Make the UIView member variable say thatView;
if(!thatView) {
thatView = [[UIView alloc] init];
[self.view addSubView:thatView];
}
Once you release the superview, release thatView & make thatView to nil.
OR
always check & remove thatView if present from superview before allocating thatView.
Hope this Helps !!!
I'm looking for popover in iPhone and i want to make it like iOS 5 Reader feature:
After little research i found WEPopover and FPPopover but i'm looking if there anything like this API built-in iphone SDK.
You could make a UIView with some custom artwork and display it with an animation on top of your view as a "popover" with some buttons like so:
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(25, 25, 100, 50)]; //<- change to where you want it to show.
//Set the customView properties
customView.alpha = 0.0;
customView.layer.cornerRadius = 5;
customView.layer.borderWidth = 1.5f;
customView.layer.masksToBounds = YES;
//Add the customView to the current view
[self.view addSubview:customView];
//Display the customView with animation
[UIView animateWithDuration:0.4 animations:^{
[customView setAlpha:1.0];
} completion:^(BOOL finished) {}];
Don't forget to #import <QuartzCore/QuartzCore.h>, if you want to use the customView.layer.
Since iOS8 we are now able to create popovers, that will be the same on iPhone, as on iPad, which would be especially awesome for those who make universal apps, thus no need to make separate views or code.
You can get the class as well as demo project here: https://github.com/soberman/ARSPopover
All you need to do is subclass UIViewController, conform to the UIPopoverPresentationControllerDelegate protocol and set desired modalPresentationStyle along with the delegate value:
// This is your CustomPopoverController.m
#interface CustomPopoverController () <UIPopoverPresentationControllerDelegate>
#end
#implementation CustomPopoverController.m
- (instancetype)init {
if (self = [super init]) {
self.modalPresentationStyle = UIModalPresentationPopover;
self.popoverPresentationController.delegate = self;
}
return self;
}
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
return UIModalPresentationNone; //You have to specify this particular value in order to make it work on iPhone.
}
Afterwards, instantiate your newly created subclass in the method from which you want to show it and assign two more values to sourceView and sourceRect. It looks like this:
CustomPopoverController *popoverController = [[CustomPopoverController alloc] init];
popoverController.popoverPresentationController.sourceView = sourceView; //The view containing the anchor rectangle for the popover.
popoverController.popoverPresentationController.sourceRect = CGRectMake(384, 40, 0, 0); //The rectangle in the specified view in which to anchor the popover.
[self presentViewController:popoverController animated:YES completion:nil];
And there you have it, nice, neat blurred popover.