I'm a little new to iOS development and am running into a little problem.
I've implemented the FB SDK for iOS login into my app, and I can login and out no problem.
However, what I'm trying to do is change the single button text from 'Log in' to 'Log out', depending on the state of the FB session.
In my appDelegate (which handles the FB session state changes), I'm calling two methods from my main view controller like this:
helloappViewController * vc = [[helloappViewController alloc]init];
[vc showLogInButton];
...and...
helloappViewController * vc = [[helloappViewController alloc]init];
[vc showLogOutButton];
The methods in helloappViewController that are being called are these:
- (void) showLogInButton {
NSLog(#"Changing button text to 'Login'.");
[self.buttonLogInLogOut setTitle:#"Login" forState:UIControlStateNormal];
}
- (void) showLogOutButton {
NSLog(#"Changing button text to 'Logout'.");
[self.buttonLogInLogOut setTitle:#"Logout" forState:UIControlStateNormal];
}
I know these methods is being called properly because I can see the console log output fine, and I know I'm logged in and out via FB because of other console log outputs I've set.
However, the button title text is not being changed.
Anyone have any idea where I might be going wrong?
Thx.
Try to move code
[self showLogInButton];
and
[self showLogOutButton];
to viewDidLoad method of the helloappViewController view controller
something like this:
helloappViewController * vc = [[helloappViewController alloc]init];
vc.fbIsConnected = YES;
in viewDidLoad:
if (self.fbIsConnect)
{
[self showLogOutButton];
}
else
{
[self showLogInButton];
}
In vc:
[[NSNotificationCenter defaultCenter] addObserver: self
selector: #selector(fbDidChange)
name: FBDidChangeNotification
object: nil];
- (void) fbDidChange
{
// change button title
}
in fb controller:
[[NSNotificationCenter defaultCenter] postNotificationName:FBDidChangeNotification object:self];
Related
I'm adding the privacy screen functionality to the hybrid Cordova app via a plugin and following the approach adviced by apple.
Though it leads to unexpected issues when I open ASWebAuthenticationSession window I use for the OAuth authentication. What happens is, when system dialogue appears with a text "Your app wants to use xxx for Sign In", it makes the app to lose a focus and the privacy screen appears behind the overlay. After I choose "Yes", the app gains focus back and the code removing the privacy screen fires, the same code also closes the freshly opened ASWebAuthenticationSession window.
The code in PrivacyScreenPlugin.m:
UIViewController *blankViewController;
#interface PrivacyScreenPlugin ()
#end
#implementation PrivacyScreenPlugin
- (void)pluginInitialize
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(onAppDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(onPageDidLoad) name:CDVPageDidLoadNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(onAppWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];
}
-(UIViewController *)createViewWithGradient {
UIViewController *viewController;
viewController = [UIViewController new];
viewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
return viewController;
}
-(void) applyPrivacyScreen
{
if (blankViewController == NULL) {
blankViewController = [self createViewWithGradient];
}
blankViewController.view.window.hidden = NO;
[self.viewController.view.window.rootViewController presentViewController:blankViewController animated:NO completion:NULL];
}
#pragma mark - Explicit Commands
- (void) hidePrivacyScreen:(CDVInvokedUrlCommand*)command
{
[self removePrivacyScreen];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void) showPrivacyScreen:(CDVInvokedUrlCommand*)command
{
[self applyPrivacyScreen];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
#pragma mark - Triggered functions
- (void) onPageDidLoad
{
[self removePrivacyScreen];
}
- (void)onAppDidBecomeActive:(UIApplication *)application
{
[self removePrivacyScreen];
}
- (void)onAppWillResignActive:(UIApplication *)application
{
[self applyPrivacyScreen];
}
#pragma mark - Helper functions
-(void) removePrivacyScreen
{
[self.viewController dismissViewControllerAnimated:NO completion:nil];
}
#end
So far I got that issue is related to the way view is dismissed, namely dismissViewControllerAnimated which dismisses the stack of modal windows:
[self.viewController dismissViewControllerAnimated:NO completion:nil];
Can it be helped or worked around? Maybe instead of removing a security screen, it can be hidden? Or is there a different way to draw the overlay which is free of the issue?
P.S. I tried to listen to UIApplicationDidEnterBackgroundNotification event, but it's not what I want. I'd like the app screen to be covered as soon as it's sent to the list of apps (via a double tap on the home button or long swipe).
To accomplish it, it's needed to render the privacy screen in a subview, instead of a modal view. It enables to hide/show a privacy screen view instead of adding/removing it:
-(void) removePrivacyScreen
{
blankViewController.view.hidden=YES;
}
-(void) applyPrivacyScreen
{
if (blankViewController == NULL) {
blankViewController = [self createViewWithGradient];
}
blankViewController.view.hidden = NO;
[self.viewController.view.window addSubview:blankViewController.view];
}
The Problem..
My app is taking me back to my main screen of the app (rootViewController) everytime I press the done button after a youtube (embedded in an iframe) video gets launched from a UIWebView which is not what I want it to do. I just want to get back to the View Controller from where this youtube video launched and display all the content within that view.
I tried using notifications to catch the state of the UIMoviePlayerController to present the previous View Controller where the youtube vide launched. But, I'm also using a navigation controller, plus this View Controller depends on a previous controller selection which uses some data to display the content within the View Controller.
I REALLY NEED SOME HELP HERE, I DON'T KNOW WHAT'S THE PROBLEM..!!
Suggestions?
Do I need to set my own MPMoviePlayerController? if so, do I have to implement some delegates to be able to controller its states and what its doing?
This is how I set my UIWebView to one of the rows in my TableView
self.videoView = [[UIWebView alloc] initWithFrame:CGRectMake(kElementX, kElementY, kElementWidth, 120)];
self.videoView.backgroundColor = [UIColor clearColor];
self.videoView.opaque = NO;
self.videoView.scalesPageToFit = YES;
//self.videoView.delegate = self;
[self.videoView setTranslatesAutoresizingMaskIntoConstraints:YES];
self.videoView.allowsInlineMediaPlayback = YES;
[cell.contentView addSubview:self.videoView];
NSString *youtubeURL = [NSString stringWithFormat:#"%#", self.url];
NSLog(#"youtube link -> %#", youtubeURL);
NSString *videoHTML = [NSString stringWithFormat:#"\
<html>\
<head>\
<style type=\"text/css\">\
iframe {position:absolute; top:0%%; margin-top:0px;}\
body {background-color:#000; margin:0;}\
</style>\
</head>\
<body>\
<div id=\"player\">\
<iframe class=\"youtube-player\" type=\"text/html\" width=\"100%%\" height=\"420px\" src=\"%#\" frameborder=\"0\" allowfullscreen></iframe>\
</div>\
<script>\
var tag = document.createElement('script');\
tag.src = \"https://www.youtube.com/iframe_api\";\
var firstScriptTag = document.getElementsByTagName('script')[0];\
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);\
var player;\
var myVideoId = document.getElementById('%#')\
function onYouTubeIframeAPIReady() {\
player = new YT.Player('player', {\
height: '100%%',\
width: '100%%',\
videoId: myVideoId,\
playerVars:{\
'autoplay':0,\
'controls':1,\
'enablejsapi':1,\
'playsinline':1,\
'showinfo':0\
events: {\
'onReady': onPlayerReady,\
}\
});\
}\
</script>\
</body>\
</html>", youtubeURL, self.url];
[self.videoView loadHTMLString:videoHTML baseURL:nil];
viewDidLoad method...
-(void)viewDidLoad{
// Using notifications to get the state of the UIMoviePlayerController
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(movieIsPlaying:) name:#"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(movieStopedPlaying:) name:#"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];
}
// Trying to stop the dismiss of the View Controller
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (self.videoLaunched) {
[super viewWillDisappear:NO];
[self dismissViewControllerAnimated:NO completion:nil];
}
}
// apparently this function besides the notifications functions is the only one which gets call after the done button is pressed (here I tried to attempt loading back the View Controller) not much luck
-(void)viewWillDisappear:(BOOL)animated{
if(self.videoLaunched)
[super viewWillDisappear:NO];
}
// Starts playing the video
- (void)movieIsPlaying:(NSNotification *)notification
{
self.videoLaunched = YES;
}
// The video stop and exit player
- (void)movieStopedPlaying:(NSNotification *)notification
{
self.videoLaunched = NO;
}
I really hope someone has come across with this problem and be able to share the solution with me.. Thanks! :)
The whole problem was that someone the the viewDidAppear or actually the NavigationViewController was getting call and because it's set to take you back to the main or actually the rootViewController of the app. It's was clearing up all the previous ViewControllers and taking me back there.
I debugged with a break point and found the problem.. So, the solution for me was setting a variable in the userDefaults just before the video is about to finish with this notification UIMoviePlayerControllerWillExitFullscreenNotification and calling the function to set this variable, and afterwards skipping the code with an if condition in my viewDidAppear which all the re-settings of ViewController whats happening in my case..
Well, I hope it helps someone else with the same or similar problem..
I've made an attempt to draw custom NSButtons, but it seems I'm reinventing the wheel here. Is there a way to just replace the default images used for the close, minimize and zoom buttons?
Several apps already do it:
OSX 10.8's Reminders app (they appear dark grey when the window is not key, vs most appear light grey)
Tweetbot (All buttons look totally custom)
More info:
I can generate the system defaults as such standardWindowButton:NSWindowCloseButton. But from there the setImage setter doesn't change the appearance of the buttons.
Edit: Since I wrote this, INAppStore has implemented a pretty nice way to do this with INWindowButton. If you're looking for a drag and drop solution check there, but the code below will still help you implement your own.
So I couldn't find a way to alter the standardWindowButtons. Here is a walkthrough of how I created my own buttons.
Note: There are 4 states the buttons can be in
Window inactive
Window active - normal
Window active - hover
Window active - press
On to the walkthrough!
Step 1: Hide the pre-existing buttons
NSButton *windowButton = [self standardWindowButton:NSWindowCloseButton];
[windowButton setHidden:YES];
windowButton = [self standardWindowButton:NSWindowMiniaturizeButton];
[windowButton setHidden:YES];
windowButton = [self standardWindowButton:NSWindowZoomButton];
[windowButton setHidden:YES];
Step 2: Setup the view in Interface Builder
You'll notice on hover the buttons all change to their hover state, so we need a container view to pick up the hover.
Create a container view to be 54px wide x 16px tall.
Create 3 Square style NSButtons, each 14px wide x 16px tall inside the container view.
Space out the buttons so there is are 6px gaps in-between.
Setup the buttons
In the attributes inspector, set the Image property for each button to the window-active-normal image.
Set the Alternate image property to the window-active-press image.
Turn Bordered off.
Set the Type to Momentary Change.
For each button set the identifier to close,minimize or zoom (Below you'll see how you can use this to make the NSButton subclass simpler)
Step 3: Subclass the container view & buttons
Container:
Create a new file, subclass NSView. Here we are going to use Notification Center to tell the buttons when they should switch to their hover state.
HMTrafficLightButtonsContainer.m
// Tells the view to pick up the hover event
- (void)viewDidMoveToWindow {
[self addTrackingRect:[self bounds]
owner:self
userData:nil
assumeInside:NO];
}
// When the mouse enters/exits we send out these notifications
- (void)mouseEntered:(NSEvent *)theEvent {
[[NSNotificationCenter defaultCenter] postNotificationName:#"HMTrafficButtonMouseEnter" object:self];
}
- (void)mouseExited:(NSEvent *)theEvent {
[[NSNotificationCenter defaultCenter] postNotificationName:#"HMTrafficButtonMouseExit" object:self];
}
Buttons:
Create a new file, this time subclass NSButton. This one's a bit more to explain so I'll just post all the code.
HMTrafficLightButton.m
#implementation HMTrafficLightButton {
NSImage *inactive;
NSImage *active;
NSImage *hover;
NSImage *press;
BOOL activeState;
BOOL hoverState;
BOOL pressedState;
}
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self setup];
}
return self;
}
- (id)initWithFrame:(NSRect)frameRect {
self = [super initWithFrame:frameRect];
if (self) {
[self setup];
}
return self;
}
- (void)setup {
// Setup images, we use the identifier to chose which image to load
active = [NSImage imageNamed:[NSString stringWithFormat:#"window-button-%#-active",self.identifier]];
hover = [NSImage imageNamed:[NSString stringWithFormat:#"window-button-%#-hover",self.identifier]];
press = [NSImage imageNamed:[NSString stringWithFormat:#"window-button-%#-press",self.identifier]];
inactive = [NSImage imageNamed:#"window-button-all-inactive"];
// Checks to see if window is active or inactive when the `init` is called
if ([self.window isMainWindow] && [[NSApplication sharedApplication] isActive]) {
[self setActiveState];
} else {
[self setInactiveState];
}
// Watch for hover notifications from the container view
// Also watches for notifications for when the window
// becomes/resigns main
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(setActiveState)
name:NSWindowDidBecomeMainNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(setInactiveState)
name:NSWindowDidResignMainNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(hoverIn)
name:#"HMTrafficButtonMouseEnter"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(hoverOut)
name:#"HMTrafficButtonMouseExit"
object:nil];
}
- (void)mouseDown:(NSEvent *)theEvent {
pressedState = YES;
hoverState = NO;
[super mouseDown:theEvent];
}
- (void)mouseUp:(NSEvent *)theEvent {
pressedState = NO;
hoverState = YES;
[super mouseUp:theEvent];
}
- (void)setActiveState {
activeState = YES;
if (hoverState) {
[self setImage:hover];
} else {
[self setImage:active];
}
}
- (void)setInactiveState {
activeState = NO;
[self setImage:inactive];
}
- (void)hoverIn {
hoverState = YES;
[self setImage:hover];
}
- (void)hoverOut {
hoverState = NO;
if (activeState) {
[self setImage:active];
} else {
[self setImage:inactive];
}
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#end
In IB set the Custom Class of the container view and all 3 buttons to their respective classes that we just created.
Step 4: Set the button actions
These methods, called from the view controller, are the same as the standardWindowButtons'. Link them to the buttons in IB.
- (IBAction)clickCloseButton:(id)sender {
[self.view.window close];
}
- (IBAction)clickMinimizeButton:(id)sender {
[self.view.window miniaturize:sender];
}
- (IBAction)clickZoomButton:(id)sender {
[self.view.window zoom:sender];
}
Step 5: Add the view to the window
I have a separate xib and view controller setup specifically for the window controls. The view controller is called HMWindowControlsController
(HMWindowControlsController*) windowControlsController = [[HMWindowControlsController alloc] initWithNibName:#"WindowControls" bundle:nil];
NSView *windowControlsView = windowControlsController.view;
// Set the position of the window controls, the x is 7 px, the y will
// depend on your titlebar height.
windowControlsView.frame = NSMakeRect(7.0, 10.0, 54.0, 16.0);
// Add to target view
[targetView addSubview:windowControlsView];
Hope this helps. This is a pretty lengthy post, if you think I've made a mistake or left something out please let me know.
I am using a UINavigationController and pushing/popping UIViewControllers onto it. In some instances I am attempting to pop to the root view controller and then push a view controller after a short delay (0.1f).
My push code for the Message View Controller is as follows. My app fires two notifications. The first to select a tab and the second to push the correct view controller onto the stack of that tab.
//user taps a button and the app needs to switch tab and push the correct viewController
//onto the tab. I have tried setting pop == NO to avoid a 'double pop' but I still get
//overlapped titles
-(IBAction)messages:(id)sender {
NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[NSNumber numberWithInt:4], [NSNumber numberWithBool:YES] , nil] forKeys:[NSArray arrayWithObjects:#"tab",#"pop", nil]];
[[NSNotificationCenter defaultCenter] postNotificationName:kAutoSelectTab object:dictionary];
[[NSNotificationCenter defaultCenter] performSelector:#selector(postNotificationName:object:) withObject:kMessages afterDelay:0.1f];
}
//responds to the first notification
-(void)autoSelectTab:(NSNotification*)notification {
NSDictionary* dictionary = (NSDictionary*)[notification object];
int tab = [[dictionary objectForKey:#"tab"] intValue];
BOOL pop = [[dictionary objectForKey:#"pop"] boolValue];
[self.tabBarController setSelectedIndex:tab];
UIViewController* vc = [[self.tabBarController childViewControllers] objectAtIndex:tab];
PSLogDebug(#"Selecting tab:%#",[vc class]);
[self tabBarController:self.tabBarController didSelectViewController:vc];
if (pop == YES) {
if ([vc isKindOfClass:[UINavigationController class]]) {
[(UINavigationController*)vc popToRootViewControllerAnimated:YES];
}
}
}
//responds to the second notification
-(IBAction)messages:(id)sender {
[self.navigationController popToRootViewControllerAnimated:NO];
MessagesViewController* vc = [[MessagesViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
}
Functionally the views appear to pop and push correctly BUT the titles do not pop and each new title is overlaid atop the old one.
I set the titles for each of the view controllers in viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.navigationItem.title = #"More";
}
When I don't attempt the pop to root followed by the delay followed by the push - the titles and views behave as expected with no overlapping occurring.
Example Images from screenshots
I've had a good dig around stack overflow but I can't see any questions which describe the same issue as the one I am having.
Qn.1: Is there something fundamentally incorrect with the popToRoot, Delay, push View approach?
Qn.2: If anyone out there has seen this kind of behaviour before, how did you resolve it?
Increasing the delay from 0.1f to 0.5f fixed the problem
Change
[[NSNotificationCenter defaultCenter] performSelector:#selector(postNotificationName:object:) withObject:kMessages afterDelay:0.1f];
to
[[NSNotificationCenter defaultCenter] performSelector:#selector(postNotificationName:object:) withObject:kMessages afterDelay:0.5f];
I have a strange issue on ios 4.3.I have one of my screen in landscape mode, a button click presents a popover.My popover has a search bar.Whenever keyboard appears it automatically pushes my popover bit up.When I resign the keyboard , popover reduces in height.This is the issue only on ios 4.3.While in rest of the ios , my popover doesnot reduces in height after keyboard dismissal.
None of the answers above worked for me. Apparently the keyboard scales the view and restores this scaling after the UIKeyboardDidHideNotification notification, making the presentPopoverFromRect method useless when applied handling this notification.
The way I solved it was by delaying the latter call as follows:
- (void)viewDidLoad
{
[super viewDidLoad];
popup = nil; //my ViewController with UITextField
popover = nil; //my UIPopoverController
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:#selector(resizePopup:)
name:UIKeyboardDidHideNotification
object:nil];
}
- (void)doDelayedResize
{
[popover presentPopoverFromRect:myButton.bounds inView:myButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
- (void)resizePopup:(NSNotification*)note
{
[self performSelector:#selector(doDelayedResize) withObject:nil afterDelay:0.01];
}
I answered a very similar question here: UIPopoverController's view controller gets resized after keyboard disappears
The way I got around it was to observe the keyboard disappearing in the controller which controls the UIPopoverController:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(presentSearchPopover) name:UIKeyboardDidHideNotification object:nil];
And then in -presentSearchPopover, present the UIPopoverController again (it's quite a seamless transition):
- (void)presentSearchPopover
{
self.searchPopoverController.popoverContentSize = CGSizeMake(width, height));
[self.searchPopoverController presentPopoverFromRect:someRect) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
Don't forget to remove the observer in -dealloc or similar too:
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidHideNotification object:nil];
[super dealloc];
}
I found an answer for this.It was a bug with the top arrow of popover.If I use the left arrow direction for popover, everything works fine.
I ran into this issue as well - specifically, the popover wasn't growing back to its pre-keyboard size after tapping away from the popover. (The popover would grow back if the user dismissed the keyboard directly or the popover's view controller resigned first responder).
Unfortunately, I have to use the top arrow direction for the popover due to the UI's layout. To solve this, the view controller responsible for the popover implements - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController. For example:
#interface MyController : UIViewController <UIPopoverControllerDelegate>
{
// ...
}
//...
#end
Set that controller as the popover's delegate:
MyPopoverViewController *popoverVC = [[MyPopoverViewController alloc] init];
UIPopoverController *myPopover = [[UIPopoverController alloc] initWithContentViewController:popoverVC];
myPopover.delegate = self;
// Hang on to popoverVC, myPopover or release them as desired...
In addition, my popover's view controller sets its contentSizeForViewInPopover property to the desired size:
#implementation MyPopoverViewController
- (id)init
{
self = [super init];
if (self)
{
// ...
self.contentSizeForViewInPopover = CGSizeMake(320, 400); // desired size
}
return self;
}
When the keyboard causes the popover to shrink, it affects the popover's popoverContentSize and not its view controller's contentSizeForViewInPopover. Therefore, reset popoverContentSize in MyController's delegate method:
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
// Check if popoverController is valid, the popover you want, etc
popoverController.popoverContentSize = popoverController.contentViewController.contentSizeForViewInPopover;
}
Here is my solution:
1. Register for keyboard Notifications (UIKeyboardWillShowNotification, UIKeyboardWillHideNotification)
2. Create local variables:
CGSize _currentPopoverContentSize; //if you want to have custom size for popover
UIView *_currentPopoverSender; //to remember from wich view you will present popover
BOOL _keyboardIsShown; //enable in keyboardWillShow, and disable in keyboardWillHide
3. In my presentPopover method:
- (void)presentPopoverControllerWithSize:(CGSize)size fromView:(UIView *)sender{
MyController *controller = [[[MyController alloc] init] autorelease];
if (self.popover)
{
[_popover release];
_popover = nil;
}
_popover = [[UIPopoverController alloc] initWithContentViewController:controller];
_popover.popoverContentSize = size;
_popover.delegate = self;
//checking if keyboard is shown - if NO, than present popover, if YES - just `resignFirstResponder` for your _`activeTextField`(you can set it in -textFieldDidBeginEditing: and nullify in -textFieldDidEndEditing:)
if (!_keyboardIsShown)
{
[_popover presentPopoverFromRect:[sender bounds]
inView:sender
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}
else
{
[_activeTextField resignFirstResponder];
}
_currentPopoverContentSize = size;
_currentPopoverSender = sender;
}
4. Than:
- (void)keyboardWillBeHidden:(NSNotification*)aNotification{
[UIView animateWithDuration:0.3
animations:^{
//do some stuff
[self.scrollView setContentSize:_scrollViewContentSize];
} completion:^(BOOL finished) {
if (_popover && _currentPopoverSender)
{
[_popover presentPopoverFromRect:[_currentPopoverSender bounds]
inView:_currentPopoverSender
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}
}];
_keyboardIsShown = NO;
}
Hi After going through the forum, I don't think it's a bug after playing with frame sizes a lot, working on IOS 4,5,6,7 it's the same behaviour.
The solution for me was to:
1) Go into the designer by
2) Opening the XIB ViewController that is causing the problem (i.e. the PopOver one).
3) Click to select it's VIEW.
4) Uncheck "AutoResizeSubviews"
5) When loading the PopOver in code, make sure you do:
6) Your_Popup_Window.popoverContentSize = Your_ViewController.view.bounds.size;
I hope this helps.
Kind Regards
Heider Sati