How to implement UITextView.hidden - objective-c

I'm developing an iOS 5 app.
I can't understand why
myTextView.hidden = YES;
or
myTextView.hidden = NO;
is not working?
I have also tried to use [myTextView setHidden:( ! [myTextView isHidden])];
I have myTextView default set to hidden through IB in the xib.
Any help would be great!
Thanks

Just try: [myTextView setHidden:YES];

Is the connection between the IBOutlet and the UITextView on the Xib file established? That's my best guess for why that's not working.
Edit: I am assuming you have create the UITextView on the Xib and not on the code.

in .h
UITextView *myTextView;
#property(nonatomic, assign) UITextView *myTextView;
in .m
[myTextView setHidden:YES];

One way you could make this operation smoother is to have an image identical to your loading image which overlays your entire view. Mark it as
[self.OverlayView setHidden:false];
so that it overlays your start screen. If you then need to display your start screen then simply set
[self.OverlayView setHidden:true];
this will give you a seamless transition to your login screen (a bit of a cludge but works great!)

Related

Xcode: Create a group of outlets

This is just a quick question, I have lots of outlets in my code that need to be hidden initially and I want to make it so that in my viewDidLoad I only have to say something along the lines of colourObjects.hidden = YES; rather than individually going through and declaring if they are hidden or not i.e. redColourObject.hidden = YES;
blueColourObjects.hidden = YES;
greenColourObjects.hidden = YES; I would find it very grateful to know if this is possible and how you do it!
Thanks for any help
Hugh
IBOutletCollection is what you need:
#property (nonatomic, strong) IBOutletCollection(UIView) NSArray *stuff;
You can drag as many outlets as you want in it and they'll be there. You can also keep the original references for other purposes. then
for (UIView *view in self.stuff) {
[view setHidden:YES];
}
Sorry but there is not a way to do that. You would have to declare that individually.
What you could do I put them all into one UIView and then hide the UIView which would hide everything in in the UIView.

UITabBar height in iOS 5

With the new customization APIs in iOS 5, is it possible to increase the height of UITabBar? If not, what are some open source options if I want to target iOS 5?
Thanks
My way of customizing UITabBarController's tabbar is to customize UITabBarController itself first.
UITabBarcontroller has two subviews inside. A UITransitionView and a UITabBar. UITransitionView is the area on the top half of the screen where you put your view controllers in.
In order to customize the height of the UITabbar, you also need to edit UITransitionView's frame. So, for instance if you want to change the heights, you can do;
[[tabbarController.view.subviews objectAtIndex:0] setFrame:CGRectMake(0, 0, 320, 440)];
[tabbarController.tabBar setFrame:CGRectMake(0, 440, 320, 50)];
This will create a 50 px height tabbar, (by default it is 48 px)
You can write a category of UItabbar
here is the code :
.h file :
#import <UIKit/UIKit.h>
#interface UITabBar (NewSize)
- (CGSize)sizeThatFits:(CGSize)size;
#end
.m file :
#import "UITabBar+NewSize.h"
#implementation UITabBar (NewSize)
- (CGSize)sizeThatFits:(CGSize)size {
CGSize newSize = CGSizeMake(size.width,44);
return newSize;
}
#end
and then
#import "UITabBar+NewSize.h"
self.tabBarController = [[UITabBarController alloc] init];
[self.tabBarController.tabBar sizeThatFits:CGSizeMake(320, 44)];
self.tabBarController.tabBar.shadowImage = [[UIImage alloc]init]; //delete the default tabbar shadow!
You cannot do that with the UITabBar. I would suggest that you create your own UIToolBarand make it appear like a tabBar, and you can add UIButtons to it and make them appear like tabBarItems.
It will appear like a tabBar and gives you a lot of room for customizations and you can also add more than 5 tabs to it and implement a "scroll" animation between the buttons. :)
I would suggest the BCTabBarController. I used it in one of my projects and it works great. You would still have to customize it, though.
It's not possible with the UIAppearance proxy
The way I'd recommend doing it is using container ViewController methodology in UIViewController (It's under the heading Implementing a Container View Controller). Apple's docs basically tell you how to roll your own.

Hide/Show UILabel with hidden property not working

I implemented the following code in my CustomViewController's method viewDidLoad to switch a label visibility on/off depending on my needs:
- (void)viewDidLoad
{
[super viewDidLoad];
myLabel.hidden=NO;
if (x==1) {
myLabel.hidden=YES;//here is correctly hidden
}
else {
[self.view bringSubviewToFront:myLabel];
if(!myLabel.hidden){
NSLog(#"I'm not hidden!");// the log displays correctly! so myLabel is not Hidden but I can't see it!
[self.view bringSubviewToFront:myLabel];
}
}
MyLabel is declared in CustomViewController.h ("IBOutlet UILabel *myLabel;") and connected to its corresponding UILabel interface in the Xib file.
Why Can't I see it even if its "hidden"property is false?
P.s the UILabel text is assigned to the UILabel interface in the xib file
thanks
Luca
solved thanks guys I feel stupid.the label was out of the stage so I could see it.I just repositioned it and now it is working fine
You got a typo in your code:
Your outlet seems to be myLabel but your if statement using mylabel (Should be with an Uppercase 'L'). Also note that the getter for this property is isHidden and not hidden as you might expected (this is not the source of the problem though, but Apple stating it in their documentation so I thought it was worth mentioning).
EDIT:
You said:
MyLabel is declared in CustomViewController.h ("IBOutlet UILabel *infoPostRist;") and connected to its corresponding UILabel interface in the Xib file.
So, shouldn't you check infoPostRist instead of myLabel then?
You can try to remove it from the view instead :
[myLabel removeFromSuperview];
Did you try your code in (void)viewWillAppear:(BOOL)animated or - (void)viewDidAppear:(BOOL)animated?
Hiding/Showing views when the view controller is loaded may not work properly.
For the sake of knowledge I answer my own question:the problem was that the label was out of the stage so I couldnt see it.I just repositioned it and now it is working fine

iPad UIPopoverController does not go over inputView in UITextView

I am trying to set up a popover to point to a UIButton in a view that is used as a "inputView" to a UITextView. I can get everything to work and the correct data is going into the UIPopoverController. But it is exhibiting a behavior that is not what I expected. So here is what I have. The following method is written in a UIView subclass that is the inputView of the UITextView and is also the view in which the button resides.
- (IBAction)buttonTouchDown:(id)sender {
UIButton *button = (UIButton *)sender;
MyPopoverContentController *controller = [[MyPopoverContentController alloc] initWithNibName:#"MyNib" bundle:nil];
[controller setContentSizeForViewInPopover:CGSize(320.0, 304.0)];
self.popupController = [[UIPopupController all] initWithContentViewController:controller];
[self.popupController presentPopoverFromRect:[button frame] inView:self permittedArrowDirectoions:UIPopoverArrowDirectionDown animated:YES];
}
Now, I would expect the popover to float over the inputView and the pointer would touch the button I've placed into the view. But it does not. In the 'X' origin the popover point is correct. But it appears the UIView when acting as a input view it won't allow the popover to move down over the inputView to the UIButton. Am I overlooking something?
Thanks for any help,
Rob
It's been a while since I visited this question. I turned this in to Apple and it is a bug. They are working on it.
Try:
[self.popupController presentPopoverFromRect:button.bounds inView:button permittedArrowDirectoions:UIPopoverArrowDirectionDown animated:YES];

UIScrollView not working with [scrollView setScrollEnabled: YES]

In my .h file, I have an IBOutlet declared like this:
IBOutlet UIScrollView *scrollView;
I wired my UIScrollView to File's Owner.
In my .m file I have the following in viewDidLoad:
[scrollView setContentSize:CGSizeMake(320, 600)];
[scrollView setScrollEnabled:YES];
But when I try to scroll, nothing happens.
You don't need to set the UIScrollViewDelegate because I've had apps that scroll without using it.
If you a are using iOS 6, using Autolayout in your .xib files can be the reason that your UIScrollView doesn't behave the way you expect it to (even though your setting a large contentSize).
You can disable Autolayout by selecting the respective .xib file in the Project Navigator and unchecking "Autolayout" in the File inspector (in the right column).
You can also adjust your Autolayout settings (there's various threads on this).
If you have taken scroll view in xib file then you do not need to below line:
[scrollView setScrollEnabled:YES];
Also you should check your connection with file's owner.